By ordering the output pwm and / or the high of the H-bridge which commands the motor dc I saw a long time ago how to produce some sounds.
But I forget that.
I want to identify with the start of the micro controller that everything is ok after the motor will be normaly commanded
A piece of code with IDE arduino would be appreciated or an URL
make few sound with a motor dc
Re: make few sound with a motor dc
froussel wrote:
A piece of code ...
did not played with this on esp32..
and not from me, but think should be can transformed to the esp32 that work's
hope this helps you:
Code: Select all
void playSound(uint16_t freq, uint16_t duration_msec, uint8_t amplitude) {
uint32_t n,k,period_usec,duration_usec;
period_usec = 1000000L / freq;
duration_usec = 1000 * (uint32_t) duration_msec;
k = duration_usec / period_usec;
motorSpeed (amplitude, amplitude);
for (n = 0; n < k; n++) {
motorDirection (DIR_FORWARD, DIR_FORWARD);
delayMicroseconds(period_usec/2);
motorDirection (DIR_REVERSE, DIR_REVERSE);
delayMicroseconds(period_usec/2);
}
motorSpeed (0, 0);
}
best wishes
rudi
sure .. here you go...or an ULR ...
and .. here
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: make few sound with a motor dc (solved)
Thanks!
Just must do it now
Just must do it now
Re: make few sound with a motor dc
I tried
No sound
please why ?
- void motorAv()
- { digitalWrite(inaPin, HIGH);
- digitalWrite(inbPin, LOW); }
- void motorAr()
- { digitalWrite(inaPin, LOW);
- digitalWrite(inbPin, HIGH); }
- void motorStop()
- { digitalWrite(inaPin, LOW);
- digitalWrite(inbPin, LOW); }
- void playSound(uint16_t freq, uint16_t duration_msec, uint8_t amplitude)
- { uint32_t n,k,period_usec,duration_usec;
- period_usec = 1000000L / freq;
- duration_usec = 1000 * (uint32_t) duration_msec;
- k = duration_usec / period_usec;
- pwm= amplitude; // pwm max driver motor = 100%
- for (n = 0; n < k; n++)
- { motorAv();
- delayMicroseconds(period_usec/2);
- motorAr();
- delayMicroseconds(period_usec/2); }
- motorStop; }
- uint16_t freq = 1000; // max 65535
- uint16_t duration_msec = 400;
- uint8_t amplitude=255;
- for (int i =15000; i < 19000; i = i +100)
- { delay(100);
- playSound(i, duration_msec, amplitude);
- }
please why ?
Re: make few sound with a motor dc
I'm alone ?
Re: make few sound with a motor dc
did you test, you can drive the motor normal?
is the motor working? how much sink it?
which motor you use?
how you drive the motor by hardware?
or do you use (later) motor drivers ics? ( example uln2003 )
and how looks your hardware setup?
best wishes
rudi
is the motor working? how much sink it?
which motor you use?
how you drive the motor by hardware?
or do you use (later) motor drivers ics? ( example uln2003 )
and how looks your hardware setup?
best wishes
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: make few sound with a motor dc
Yes
Brushed DC motoris the motor working? how much sink it?
which motor you use?
Thing as https://www.pololu.com/product/708how you drive the motor by hardware?
or do you use (later) motor drivers ics? ( example uln2003 )
and how looks your hardware setup?
When reading this
http://esp8266.github.io/Arduino/versio ... log-output
I wonder if I have an error in the maximum of 255 for the pwm
Should not I put 1023 instead?
Alsobest wishes
rudi
-
- Posts: 1
- Joined: Tue Oct 15, 2019 7:18 am
Re: make few sound with a motor dc
did you test, you can drive the motor normal?
is the motor working? how much sink it?
which motor you use?
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
My stepper motor website:skysmotor.com - Machinery Design - Stepper Moter Development
"Necessity is the mother of invention." - Author unknown.
as you type.
is the motor working? how much sink it?
which motor you use?
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
My stepper motor website:skysmotor.com - Machinery Design - Stepper Moter Development
"Necessity is the mother of invention." - Author unknown.
as you type.
Who is online
Users browsing this forum: Google [Bot] and 110 guests