Arduino based USB Pendant for Linuxcnc
- Miselph
- Offline
- New Member
- Posts: 15
- Thank you received: 1
Just thought I would share the progress of my Arduino based pendant.
At the moment it lives on a breadboard, pending the construction of the required PCB. I am using an Arduino Nano as it has everything I need, including FTDI usb to serial chip and is very small.
I was not happy with the amount of time that the standard Keypad library took, so I wrote my own that uses direct port manipulation rather than digitalRead and digitalWrite and I reduced the scan time from 430us to 20 us. Unfortunately this used the majority of my pins, so the LCD has been attached on the SPI bus, clocking the bits out at 8MHz to a 74HC595 shift register; a full update of the screen takes 14ms. The purpose of these speedups is to leave more runtime available for serial processing. The keypad is scanned every 10ms using a timer based interrupt so as to ensure that I don't miss any key strokes and keystrokes entered into a buffer. Another feature I have added to my Keypad library is the ability to return the keypad status as two bytes, with each key represented by 1 bit. This reduces the amount of data that has to be transferred to two bytes, regardless of how many keys are active. Keys can also be set up as either momentary or toggle.
I have also begun work on a serial packet-based protocol for reliable communication of different data types. So far I can send integers and strings with no problem. The reason for this is that I am intending to use wireless which is especially prone to data loss so I need a protocol with error checking and rejection in it; we don't want the machine doing strange things due to corrupted data now do we? It would be a good idea to adopt such a protocol regardless of connection type, as any connection will suffer some data loss from time to time.
More information as I progress.....
Chris
Please Log in or Create an account to join the conversation.
- VNR
- Offline
- Senior Member
- Posts: 61
- Thank you received: 7
I have succesfully connected an arduino to HAL using modbus protocol wich have CRC packet verification. May be you want to test it.I have also begun work on a serial packet-based protocol for reliable communication of different data types. So far I can send integers and strings with no problem. The reason for this is that I am intending to use wireless which is especially prone to data loss so I need a protocol with error checking and rejection in it; we don't want the machine doing strange things due to corrupted data now do we? It would be a good idea to adopt such a protocol regardless of connection type, as any connection will suffer some data loss from time to time.
I don't have tested it with wireless, so i don't know if it will work in this case, but now it is working for me with an Arduino Mega 2560 R3 board, a Modbusino library (modbus) and a USB cable at 115200 bps.
The source code is here: sourceforge.net/tracker/?func=detail&aid..._id=6744&atid=356744
The protocol transfers integers and bits in 2 ways by default, but you could packet a float into 2 integers and a string into an array of integers if you need them.
Regads,
Victor
Please Log in or Create an account to join the conversation.
- r00t4rd3d
- Visitor
arduino.cc/en/Main/ArduinoBoardEsplora
Please Log in or Create an account to join the conversation.
- rthorntn
- Offline
- Junior Member
- Posts: 31
- Thank you received: 6
The touchscreen has a microcontroller on board that communicates with the outside world using using serial.
My issue is I am new to linuxcnc, can only do very basic programming and so I am wondering if me trying to do this is feasible?
Thanks
Richard
Please Log in or Create an account to join the conversation.
- tkamsker
- Offline
- Premium Member
- Posts: 129
- Thank you received: 5
i think it is much easier than that
Why do you want an pendant with touchscreen ?
I do have an lcd for my info and have a lot of buttons fro jog start stop pause and so on
and an quadrature encoder for jogging itself
so i dont know what the lcd should be good for
if you think of haveing all your display as touchsscreen it is also possible
and the pendant is the quadrature only that is ou of the box
thomas
Please Log in or Create an account to join the conversation.
- KenC
- Offline
- Premium Member
- Posts: 99
- Thank you received: 0
Please Log in or Create an account to join the conversation.
- cnc_mill
- Visitor
You Have done a Great Job but i need a little Help from Your side.
I am a Near 50 year old millmen with poor english knowlege and no idea of Coding. My best friend is the Leodic ^^
i have Build your Pendant and want to run it but i find no way where i should put the
serialcon.comp
I Have Done "sudo apt-get install linuxcnc-dev"
I have given the missing moduls of arduino in the library
but where i must i put the comp with directory does you mean?
i have try to read the manual hal component generator but i dont find a way to place them
where must i put a code to start the component
my first attempt wars verry unusefull so i have to reinstall Linuxcnc i crash't them complete
please can you give a little help to get them run
thank you and have a good day
Franz
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
- Posts: 25
- Thank you received: 761
Copy the file serialcon.comp to your config folder for the machine using the pendant. Could be anywhere but that is most logical.
In a terminal cd to that config directory and use the command
sudo comp --install serialcon.comp
That will build the userspace module and copy it to /usr/bin, for your type of install
The line loadusr -W serialcon goes in your postgui.hal file normally and then you join up the pins as required, as per the previous posts
regards
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
- Posts: 25
- Thank you received: 761
Just an update.
I have been using my pendant quite a lot recently.
I upgraded my big mill to Mesa 5i25 / 7i76 cards and hard wired the pendant I used to have connected to a parport card, into the 7i76 encoder and IO interfaces.
This means that on my small mill, which shares the same computer, I now have no other pendant option.
I have re-written some of the code.
The polling rate is increased to every 10th of a second and the baud rate increased to 115200
There is now a check on the data received and the LCD display is only updated when it differs from the previous data.
The jogging logic is slightly changed.
After selecting the jog velocity and enabling jog, a press on a direction arrow jogs until the button is pressed again, or the jog enable button is pressed.
The velocity can be changed mid jog without stopping, useful when you are nearing the target and want accuracy.
Overall the pendant is much more responsive and the display is rock steady.
I have zipped up the new code, the versions of the arduino libraries I used for keypad, LCD and serial ( because they have changed) and a config folder that runs a sim which interacts with the pendant.
Instructions for building and changing the code to match your particular arduino / jog increment requirements etc. remain the same as per earlier posts
regards
Please Log in or Create an account to join the conversation.
- tome
- Offline
- Premium Member
- Posts: 134
- Thank you received: 11
I have a toolchanger board driven by an Arduino (nano) and I want to modify your serialcon2 component in order to send tool requests to the Arduino and receive tool change completed signal from the Arduino over USB. However I cannot get the component to build. I have the Linuxcnc-dev stuff installed but I do not have the "comp" program in order to put it my config directory and build it. I did do the other instructions I found on the net which is to put the .comp file into /linuxcnc-dev/src/hal/components/ and then make. But I get a failure that stdlib.h isn't found:
tom@EMCO-120P:~/linuxcnc-dev/src$ make
Reading 183/183 dependency files
Done reading dependencies
Creating serialcon2.mak
Reading 183/183 dependency files
Done reading dependencies
Preprocessing serialcon2.comp
MAKEFLAGS="" \
/usr/bin/python modsilent.py make KBUILD_EXTRA_SYMBOLS=/usr/realtime-3.4-9-rtai-686-pae/modules/Module.symvers -C /usr/src/linux-headers-3.4-9-rtai-686-pae SUBDIRS=`pwd` CC=gcc V=0 modules
make[1]: Entering directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
CC [M] /home/tom/linuxcnc-dev/src/objects/hal/components/serialcon2.o
make[1]: Leaving directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
/home/tom/linuxcnc-dev/src/objects/hal/components/serialcon2.c:30:20: fatal error: stdlib.h: No such file or directory
compilation terminated.
make[4]: *** [/home/tom/linuxcnc-dev/src/objects/hal/components/serialcon2.o] Error 1
make[3]: *** [_module_/home/tom/linuxcnc-dev/src] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make: *** [modules] Error 2
I re-ran ./configure just to be sure it could find things, and I can see /usr/include/stdlib.h exists but no luck. I also tried to edit the .comp file and make the include line: #include </usr/include/stdlib.h> which I know is ugly, and that still failed with the error above. What am I missing?
EDIT: I am building this on 2.7~pre6 on Debian Wheezy.
Thanks,
Tom
Please Log in or Create an account to join the conversation.