Hello,
I have a program wherein i read ADC as integer potentiometer location and read target location ADC as integer (0-1023). I then get the distance between the two by comparing the potentio reading to the target (either Distance=target-reading or Distance=reading-target whichever is higher). If the distance is small (around 120), the motor should slow down. Simulation of this program is perfect.
Ex. Target= 860
Reading = 184
Distance= Target-Reading = 676
Why is it that in my actual application, the motor slows down at a reading of approximately 604 (which is a distance of 860-604=256)? This is quite far.
Another observation is that I don't seem to have this problem when I go in the opposite direction.
Ex. Target= 184
Reading = 860
Distance= Reading-Target = 676
The motor seems to behave correctly. It slows down at a distance of around 120.
Am I missing something here? Please help.
Thanks
Simulation is ok but actual application behaves differently
Moderator: Benj
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Simulation is ok but actual application behaves differen
Hello mimiyum.
It would be difficult without your hardware and on the information you have given, to try and locate the cause of problem. My suggestion would be to use ICD tool, and single step, to confirm calculations are behaving as expected with the real hardware.
I have use ICD on a few occasions, with great success.
What I do is use one chip which costs more, but has more memory just for debugging. Then when happy with results, use a cheaper chip for the actual hardware.
The other option is use RS232 to usb converter. Then send variable values, and names etc to RS232. Then you can read values on PC Screen. E.G ADC0=123
ADC1=212. output = 23. PWM=24%
Target= 242
Reading = 540
Distance = 324
etc.
It would be difficult without your hardware and on the information you have given, to try and locate the cause of problem. My suggestion would be to use ICD tool, and single step, to confirm calculations are behaving as expected with the real hardware.
I have use ICD on a few occasions, with great success.
What I do is use one chip which costs more, but has more memory just for debugging. Then when happy with results, use a cheaper chip for the actual hardware.
The other option is use RS232 to usb converter. Then send variable values, and names etc to RS232. Then you can read values on PC Screen. E.G ADC0=123
ADC1=212. output = 23. PWM=24%
Target= 242
Reading = 540
Distance = 324
etc.
Martin