Simulation is ok but actual application behaves differently

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
mimiyum
Posts: 94
Joined: Wed Jul 16, 2008 4:39 pm
Location: Philippines
Been thanked: 1 time
Contact:

Simulation is ok but actual application behaves differently

Post by mimiyum »

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

medelec35
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

Post by medelec35 »

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.
Martin

Post Reply