Page 1 of 1

Something funny going on...

Posted: Thu Oct 06, 2016 4:11 pm
by Chris_MIRA
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

Re: Something funny going on...

Posted: Fri Oct 07, 2016 7:54 pm
by johnsondav
Hi Chris

I am obviously not sure what your program is doing but, I would suggest you check that the assigned macro/variable you are using to read the 'POT' is 10-Bit wide (this is what is showing up in the properties window). This would produce a value greater than 0-255.
ADC_Pot 10-Bit Width
ADC_Pot 10-Bit Width
ADC_Pot.jpg (70.75 KiB) Viewed 4742 times

Just a thought.

Regards

Re: Something funny going on...

Posted: Mon Oct 10, 2016 7:47 am
by Chris_MIRA
Hi,
Thanks for your idea, it isn't the reading of the POT that appears to be the problem, the pot is read in manual mode and this works fine, the problem seems to be that the PWM doesn't set to the value read from CAN in auto mode.
Regards,
Chris

Re: Something funny going on...

Posted: Wed Oct 12, 2016 10:49 am
by Benj
Hi Chris,

I instantly thought it might be timer related. However I see you are using timer 1 in your program and timer 0 for the PWM.

As a sanity check maybe try switching to timer 2 in your program and see if that makes any difference.

Re: Something funny going on...

Posted: Fri Oct 14, 2016 8:02 pm
by celebriums
Hi Chris Mira,
Can you look Rev 1.0. :D