Collect data from a button push or opening a switch

Thread Starter

Hubbs

Joined Aug 8, 2019
4
I want to create a simple 2D Data capture rig. I have the X and Y axes counting using some simple rotary encoders. I have a switch attached to a pole and want to whenever the switch is initially pressed (like a RISING or FALLING Edge trigger) to capture the position data from the X and Y. I want to use an interrupt routine (like below) so it only works the instance the switch is pressing and so the X Y position is still being updated in real time.
upload_2019-8-9_16-22-5.png

One issue i have run into this is the data grab is not working (keeps displaying the same X Y data from the first time the switch is pressed). I want to collect the X and Y position, send the data to a computer program like excel or notepad and then clear the data so the next time the switch is pressed somewhere else it will collect the new data, rinse and repeat.

Is there a better method for doing this?
 

Attachments

KeithWalker

Joined Jul 10, 2017
3,050
I want to create a simple 2D Data capture rig. I have the X and Y axes counting using some simple rotary encoders. I have a switch attached to a pole and want to whenever the switch is initially pressed (like a RISING or FALLING Edge trigger) to capture the position data from the X and Y. I want to use an interrupt routine (like below) so it only works the instance the switch is pressing and so the X Y position is still being updated in real time.
View attachment 183567

One issue i have run into this is the data grab is not working (keeps displaying the same X Y data from the first time the switch is pressed). I want to collect the X and Y position, send the data to a computer program like excel or notepad and then clear the data so the next time the switch is pressed somewhere else it will collect the new data, rinse and repeat.

Is there a better method for doing this?
Yes there is:

View attachment 183574 READDATA.jpg
 

Thread Starter

Hubbs

Joined Aug 8, 2019
4

Hello Dana,

Thank you for the response. I think that is where I may have had some issues. The data is supposed to use the latest X and Y values every time the interrupt is triggered. and then send those two values to a PC via the serial port. I wish the code was on this PC so I could post it. I might be able to get it later though.

I think the articles you posted should help with my understanding of interrupt routines and sending data via serial comms.

Regards,

Matt
 

Thread Starter

Hubbs

Joined Aug 8, 2019
4
What is the rate and size (bytes of x and y) of samples being generated ?

Regards, Dana.
Currently I am using the long data type for the stored X and Y variable.

X and Y can be anything from 0 to 4 billion (based on the encoder count)

Rate? if you mean baud rate its set at 115200. The Clock oscillator is set at 40MHz. Sorry if this is not what you are looking for.
 

KeithWalker

Joined Jul 10, 2017
3,050
Currently I am using the long data type for the stored X and Y variable.

X and Y can be anything from 0 to 4 billion (based on the encoder count)

Rate? if you mean baud rate its set at 115200. The Clock oscillator is set at 40MHz. Sorry if this is not what you are looking for.
How quickly is the data from the encoder changing?
 

Thread Starter

Hubbs

Joined Aug 8, 2019
4
I have the delay in the loop of 10 milliseconds but the LS7366R counter chips should be keeping count after every pulse.
 

danadak

Joined Mar 10, 2018
4,057
How many quaddecs are you using and would 28 Mhz be adequate for quaddec clock ?

In addition what else is design doing,? You interested if this can all be done on one chip ?
Depending of course what else in design that has to be done.

Might also be possible to dma the data to UART w/o CPU intervention....


Regards, Dana.
 
Top