Collecting data with Arduino and Python

More
14 Aug 2012 17:37 #23184 by andypugh
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)

Please Log in or Create an account to join the conversation.

More
14 Aug 2012 18:00 #23189 by mcenter
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

Please Log in or Create an account to join the conversation.

More
14 Aug 2012 19:02 #23205 by ArcEye
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?
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.

More
14 Aug 2012 21:20 #23212 by mcenter
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

File Attachment:

File Name: data_recor...7c37c.py
File Size:2 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
15 Aug 2012 01:28 #23219 by mcenter

File Attachment:

File Name: data_recor...52ea7.py
File Size:2 KB


I am having problems posting my file. Maybe it will work this time.

Mark
Attachments:

Please Log in or Create an account to join the conversation.

More
15 Aug 2012 01:31 #23220 by mcenter
Sorry, I should have read this before posting

File Attachment:

File Name: data_recorder.txt
File Size:2 KB


www.linuxcnc.org/index.php/english/compo...&id=342&catid=29#342
Attachments:

Please Log in or Create an account to join the conversation.

More
15 Aug 2012 06:12 #23225 by cmorley
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

Please Log in or Create an account to join the conversation.

More
15 Aug 2012 19:43 #23258 by mcenter
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,
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.

File Attachment:

File Name: data_recor...8bcb.txt
File Size:2 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
15 Aug 2012 19:52 #23260 by mcenter
My HAL file.
I don't know how to place multiple files in one post.

File Attachment:

File Name: data_recorder.hal
File Size:0 KB

Now, I just need to connect my spindle. :(
Attachments:

Please Log in or Create an account to join the conversation.

More
15 Aug 2012 20:24 - 15 Aug 2012 20:25 #23262 by BigJohnT
Holy Moly! what is it?

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.151 seconds
Powered by Kunena Forum