Something funny going on...
Posted: Thu Oct 06, 2016 4:11 pm
Hi,
In the attached programme; there are two modes, manual and Auto. In manual, the nano reads in a pot value and sends out a PWM signal with duty cycle set to the pot value. This works fine and I get a fully controlled PWM output.
In Auto, the nano receives a CAN message, checks the right id, and takes a byte value from DO of the CAN message. The PWM duty cycle is then set to the value of DO. The nano then repeats back over CAN the value it thinks its set the PWM to. all values are decimal byte (ie 0 to 255).
The problem is that, in Auto, the PWM does not set to the CAN value until the CAN value is greater than about 200, the PWM then rises as the CAN value rises to a MAX of about 4 volts at a CAN value of 255. Im sure this is a scaling or number format issue but can not find where..... Please help!
Regards,
Chris
In the attached programme; there are two modes, manual and Auto. In manual, the nano reads in a pot value and sends out a PWM signal with duty cycle set to the pot value. This works fine and I get a fully controlled PWM output.
In Auto, the nano receives a CAN message, checks the right id, and takes a byte value from DO of the CAN message. The PWM duty cycle is then set to the value of DO. The nano then repeats back over CAN the value it thinks its set the PWM to. all values are decimal byte (ie 0 to 255).
The problem is that, in Auto, the PWM does not set to the CAN value until the CAN value is greater than about 200, the PWM then rises as the CAN value rises to a MAX of about 4 volts at a CAN value of 255. Im sure this is a scaling or number format issue but can not find where..... Please help!
Regards,
Chris