Beaten by the encoders
fader700
Posts: 9
in Propeller 1
Hello
I started this project by connecting 2 linear encoders and downloaded 'quadrature encoder' from obex and everything work a treat first time.
I then created some spin to capture a position from each encoder at regular intervals, every 0.4mm. I store these in two sets of longs and once recording has ended it is written to a USB stick in a VDrive2. Getting all this to work was pretty tricky for a novice but it worked until I required a reference mark and needed to reverse the direction of one axis. The axis used to trigger the data capture. I got the reference marker working fine and reversed the direction of travel, all the results are negative but thats fine.
when I check the data the count for the reversed axis is not zeroing correctly, the first trigger should be at -4000 counts but data recorded is starting around -255000, resolution is 0.0001mm so its 25.5mm. I doubt that is relevant as sometimes it starts around -140000.
Really would appreciate some help with this.
Andy
I started this project by connecting 2 linear encoders and downloaded 'quadrature encoder' from obex and everything work a treat first time.
I then created some spin to capture a position from each encoder at regular intervals, every 0.4mm. I store these in two sets of longs and once recording has ended it is written to a USB stick in a VDrive2. Getting all this to work was pretty tricky for a novice but it worked until I required a reference mark and needed to reverse the direction of one axis. The axis used to trigger the data capture. I got the reference marker working fine and reversed the direction of travel, all the results are negative but thats fine.
when I check the data the count for the reversed axis is not zeroing correctly, the first trigger should be at -4000 counts but data recorded is starting around -255000, resolution is 0.0001mm so its 25.5mm. I doubt that is relevant as sometimes it starts around -140000.
Really would appreciate some help with this.
Andy
Comments
This morning I seem to have much bigger issues, I have stripped my capture loop down to very little as it did not seem to be waiting for the if statement at all.
variable sample is not changing in this loop, when I move the encoder and counters[0] is greater than sample my debug output shows a stream of 4000,4000,4000,4000 etc. If I pull the encoder back the loop stops.
I changed the variable name from trigger to sample to see if it made a difference, that's how lost I am
Andy
now the output is
40008000,4000,4000,4000,4000 etc
confused me even more now...
x >= y does the same thing as x := x > y, in the same way that x += y does the same thing as x := x + y. The greater than or equal to operator in Spin is =>, and the less than or equal to operator is =<.
TChap, that's exactly what I did, I started again with just the encoders counting. This is where I started originally and started building from there.
This time everything worked just fine until writing the data to usb, this time instead of getting the delimiter written to usb it is writing the filename instead.
4002test.csv-89
8006test.csv-117
1005test.csv-469 etc.
I think the problem lies with the fact I'm running 'FullDuplexSerial' for human interfacing and the 'USBDrive' object is also running 'FullDuplexSerial' to write to the USB. Today I am going to take the elements of 'USBDrive' I am using and transplant them into my code so I can run two instances of 'FullDuplexSerial' and be in control of them.
Cheers
Andy
What troubles me about the problems I have had is that I have not understood why, I have just found solutions. This means I learn nothing from my mistakes! Sometimes a change somewhere in the code can affect areas seemingly unconnected, I am taking this as an indicator that my code is not very robust.
Thanks for your input.
Andy