To Control the speed of the elecrow H Bridge motor shield you apply a pwm signal to pin 9.
I understand the pwm ranges from 0 to 255 max.
The power input for the motor is 12 volts dc. If I analogWrite(9,254) I should get 12 volts, I get 8 volts. So I tried analogWrite(9,1022) , which I understand is not legal, I get the full 12 volts.
With an Uno or Mega, for example, analogWrite(pin, 255); is identical to digitalWrite(pin, HIGH);
It is not easy to measure the voltage from a PWM signal because the whole concept of PID is based on the motor coils averaging the PWM. In theory a PWM signal alternates between High volts and zero volts at the PWM frequency.
Viewing the motor voltage with an oscilloscope will show you what is happening.
As mentioned earlier the "legal " value 255 does not give full output
Where does it say that? I only saw 254 mentioned.
How are you measuring these voltages? (Hint: A correct answer does not include the words "Cheap digital multimeter")
The source code is the actual code that implements the analogWrite function; on my computer, this is in /usr/share/arduino/hardware/arduino/cores/arduino/wiring_analog.c
On the elecrow.com "Dual motor H Bridge ", 255 locks up the Bridge, maximum allowed is 254 which should still give close to the h Bridge input voltage (12 volts dc) not the 8 volts I am getting.
I have read that the pwm can be affected by the timers, Pin9 uses timer1, and scale, also frequency was mentioned. I have no experience with timers.
I will try looking at the source code, not sure what I'm looking for but will try as suggested
Iam talking about the h Bridge output voltage not the pwm Control voltage.
I have connected a dc motor, an led and multimeter to the Bridge output.
They all show reduced voltage at 254 compared to 1022.
My key question is how can an illegal value of 1022 compile and work. Even the manufacture of the Bridge says it should give an overflow.
The only possibility I can see, by Googling like crazy, is the pwm value may be affected by the "timer1" and possibly scale factor, neither of which I have working knowledge, hence my posting here and request for help
Grarpb:
They all show reduced voltage at 254 compared to 1022.
What happens if you try 255?
My key question is how can an illegal value of 1022 compile and work. Even the manufacture of the Bridge says it should give an overflow.
The only possibility I can see, by Googling like crazy, is the pwm value may be affected by the "timer1" and possibly scale factor, neither of which I have working knowledge, hence my posting here and request for help
I have no idea. But all the source code is included with the Arduino IDE so you can easily study it to find the answer.