Collecting data with Arduino and Python
14 Aug 2012 17:37 #23184
by andypugh
Replied by andypugh on topic Re:Collecting data with Arduino and Python
I think the problem is that your Python code runs to completion the first time, then is not called again,
Your Python code needs to set itself up, issue a hal_ready then enter a busy-loop which polls the data. Unlike realtime components userspace components are not polled by the threads.
(Or, all this could be wrong, I am not very good at reading Python)
Your Python code needs to set itself up, issue a hal_ready then enter a busy-loop which polls the data. Unlike realtime components userspace components are not polled by the threads.
(Or, all this could be wrong, I am not very good at reading Python)
Please Log in or Create an account to join the conversation.
14 Aug 2012 18:00 #23189
by mcenter
Replied by mcenter on topic Re:Collecting data with Arduino and Python
Andy,
I think you are pointing me in the right direction. However, the code does not complete until LinuxCNC shuts down. In other words, the file opens when LinuxCNC begins, however it is not called again until shut down.
Mark
I think you are pointing me in the right direction. However, the code does not complete until LinuxCNC shuts down. In other words, the file opens when LinuxCNC begins, however it is not called again until shut down.
Mark
Please Log in or Create an account to join the conversation.
14 Aug 2012 19:02 #23205
by ArcEye
Replied by ArcEye on topic Re:Collecting data with Arduino and Python
I don't know if posting it removed indentation and I have never seen the referencing you used for the pins before
What happens if you write it like this?
regards
What happens if you write it like this?
try:
basetime = time.time()
while 1:
delT = time.time() - basetime
if h.record == 1:
ain = pollArduino()
f.write(str( h.xpos) +","+ str(h.ypos)+','+str(ain)+','+str(h.sp)+','+str(delT)+'n')
time.sleep(1)
except (KeyboardInterrupt,):
raise SystemExit, 0
regards
Please Log in or Create an account to join the conversation.
14 Aug 2012 21:20 #23212
by mcenter
Replied by mcenter on topic Re:Collecting data with Arduino and Python
ArcEye,
Yes, I think l the indents were stripped. And that is terribly important in Python.
The references are similar to how Jeff Epler did it in his arduino.py script.
My Python script works when executed outside LinuxCNC in conjunction with halrun.
But, I will try it the way you suggest. I think it is less confusing.
I will try to post my script again.
Mark
Yes, I think l the indents were stripped. And that is terribly important in Python.
The references are similar to how Jeff Epler did it in his arduino.py script.
My Python script works when executed outside LinuxCNC in conjunction with halrun.
But, I will try it the way you suggest. I think it is less confusing.
I will try to post my script again.
Mark
Please Log in or Create an account to join the conversation.
15 Aug 2012 01:28 #23219
by mcenter
I am having problems posting my file. Maybe it will work this time.
Mark
Replied by mcenter on topic Re:Collecting data with Arduino and Python
I am having problems posting my file. Maybe it will work this time.
Mark
Please Log in or Create an account to join the conversation.
15 Aug 2012 01:31 #23220
by mcenter
Replied by mcenter on topic Re:Collecting data with Arduino and Python
Sorry, I should have read this before posting
www.linuxcnc.org/index.php/english/compo...&id=342&catid=29#342
www.linuxcnc.org/index.php/english/compo...&id=342&catid=29#342
Please Log in or Create an account to join the conversation.
15 Aug 2012 06:12 #23225
by cmorley
Replied by cmorley on topic Re:Collecting data with Arduino and Python
So looking at your watch window pic:
There still seems to be the same problem : the component pin names are the signalnames.
and the signal name 'record-flag' (for instance) is not seen.
Chris M
There still seems to be the same problem : the component pin names are the signalnames.
and the signal name 'record-flag' (for instance) is not seen.
Chris M
Please Log in or Create an account to join the conversation.
15 Aug 2012 19:43 #23258
by mcenter
Replied by mcenter on topic Re:Collecting data with Arduino and Python
With you guy's assistance, I have been able to get it to work!
My first problem (before I started posting) was with my $PATH where my component was at. The Integrators manual mentions this, but doesn't give a suggestion of how to do it like,
My biggest problem was that I was editing files on my thumb drive instead of in my configs directory (sneakernet)
But also, creating pins in my component that would connect to machine and halui pins. If a machine pin is OUT and FLOAT, the component pin must be IN and FLOAT.
My first problem (before I started posting) was with my $PATH where my component was at. The Integrators manual mentions this, but doesn't give a suggestion of how to do it like,
PATH=$PATH:/my/path/foo
export PATH
My biggest problem was that I was editing files on my thumb drive instead of in my configs directory (sneakernet)
But also, creating pins in my component that would connect to machine and halui pins. If a machine pin is OUT and FLOAT, the component pin must be IN and FLOAT.
Please Log in or Create an account to join the conversation.
15 Aug 2012 19:52 #23260
by mcenter
Replied by mcenter on topic Re:Collecting data with Arduino and Python
My HAL file.
I don't know how to place multiple files in one post.
Now, I just need to connect my spindle.
I don't know how to place multiple files in one post.
Now, I just need to connect my spindle.
Please Log in or Create an account to join the conversation.
15 Aug 2012 20:24 - 15 Aug 2012 20:25 #23262
by BigJohnT
Replied by BigJohnT on topic Re:Collecting data with Arduino and Python
Holy Moly! what is it?
mcenter wrote:
Zip the files up then attach them...
John
mcenter wrote:
My HAL file.
I don't know how to place multiple files in one post.
Zip the files up then attach them...
John
Last edit: 15 Aug 2012 20:25 by BigJohnT.
Please Log in or Create an account to join the conversation.
Time to create page: 0.101 seconds