Build Thread Teensy Up/Down Torch Height Control - Page 4


Page 4 of 4 FirstFirst 1234
Results 37 to 48 of 48

Thread: Teensy Up/Down Torch Height Control

  1. #37
    Registered
    Join Date
    Jun 2015
    Location
    Sweden
    Posts
    486
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    I think the Neuron THC using ethernet connection and it's own communication via plugin, but the UCCNC has a modbus master plugin.
    I have used that for some experiments and it is simple to use. You just setup a communication channel, a COM port or virtual COM on USB or TCP/IP and you write and read into the UCCNC modbus registers and then it sends the data via the communication channel. The harder part is probably the Teensy side of coding to receive and send data.



  2. #38
    Registered
    Join Date
    Oct 2010
    Location
    USA
    Posts
    313
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    Quote Originally Posted by OlfCNC View Post
    I think the Neuron THC using ethernet connection and it's own communication via plugin, but the UCCNC has a modbus master plugin.
    I have used that for some experiments and it is simple to use. You just setup a communication channel, a COM port or virtual COM on USB or TCP/IP and you write and read into the UCCNC modbus registers and then it sends the data via the communication channel. The harder part is probably the Teensy side of coding to receive and send data.
    I've found a few examples of modbus on arduino but it's all a bit over my head at the moment. Do you know of any examples with modbus on UCCNC? Most of what I find is for Mach.



  3. #39
    Registered
    Join Date
    Jun 2015
    Location
    Sweden
    Posts
    486
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    There's a document of the modbus plugin in the Documentation folder of the UCCNC. It shows how to read and write registers, how to setup a communication channel etc.



  4. #40
    Registered
    Join Date
    Oct 2010
    Location
    USA
    Posts
    313
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    I did more research and it doesn't look like I can add the SD card off the LCD without having a detrimental effect on the loop time at least for logging purposes. On the Teensy 3.1 the loop is running around 175k times per second and at minimum I would like to store incoming frequency/voltage, target, hysteresis, and output status. I don't see a way to buffer that much information and then do a write when incoming voltage drops to near 0, I also used a pin required for the SD library as an output so the PCB would need modified. I did purchase an OpenLog so I'll see how far I can get sending the information over serial and letting it handle the buffer.



  5. #41
    Registered
    Join Date
    May 2015
    Location
    Australia
    Posts
    196
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    I've just forgotten the name of the library but there is some Arduino code that buffers data writes and achieves very fast speeds writing to disk from a memory buffer sa large as you can make. Also, you really should be using an interrupt service routine to poll the voltage. It seems that your frequency library uses one timer interrupt but I think there is another you could use. So let the ISR poll the voltage and the loop can do things at a more leisurely pace. Sorry but I've got too much linuxcnc code running through my head to go back to the arduino to help further.

    Rod Webster
    www.vehiclemods.net.au


  6. #42
    Registered
    Join Date
    Oct 2010
    Location
    USA
    Posts
    313
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    Quote Originally Posted by rodw View Post
    I've just forgotten the name of the library but there is some Arduino code that buffers data writes and achieves very fast speeds writing to disk from a memory buffer sa large as you can make. Also, you really should be using an interrupt service routine to poll the voltage. It seems that your frequency library uses one timer interrupt but I think there is another you could use. So let the ISR poll the voltage and the loop can do things at a more leisurely pace. Sorry but I've got too much linuxcnc code running through my head to go back to the arduino to help further.
    I'm not sure I understand how/why a different interrupt would be helpful, there is code checking if a value is available from FreqCount before doing any of the math to find the torch voltage. I did make some more changes last night so the outputs are only modified if the change is different from current status, before it was attempting to set an output every loop even if it was already set high/low.



    Todo:

    I'm going to add an output for ArcOK and rework the PCB to add another transistor as this seems to be a common feature on other units to support plasma cutters without that output. I'm thinking that I will set the output if the incoming frequency is 5% of the THCAD range above the low. So if the range for 0-10v is 100k-900k, the ArcOK output would go high at 140k or in the case of a Hypertherm with 50:1 divider the torch would be at 25 volts. I'm sure this could be lower but that seems like a pretty safe value.

    Also going to attempt to get the Modbus working on a separate Teensy and try serial communication between the two and depending on what the whole Modbus code looks like I may try to integrate it with the THC code. I would really like to keep the loop time as quick as possible and let the software (UCCNC in this case) act on it accordingly but I should be able to remove all the LCD code once Modbus is working.



  7. #43
    Registered
    Join Date
    Oct 2010
    Location
    USA
    Posts
    313
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    Has anyone been able to get the code from Arduino Modbus, Complete, Documented and free working on a Teensy? I've set it up on an Uno and anything set as an input shows up as a 1 on the variables table and I'm able to toggle them to 0 by grounding that input but when I load the code on the Teensy, none of the variables toggle or start as a 1. I've tried changing Freq to match the 48MHz of the Teensy LC and still nothing.



  8. #44
    Registered
    Join Date
    Oct 2010
    Location
    USA
    Posts
    313
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    So after some more reading, it doesn't appear that I can work directly with values (ex: tip voltage = 122.6) and I need to use analog in/pwm out which works as a 0-255 value in the Modbus. I should be able to work with this for setting outputs to the Arduino as I could just set the PWM to 120 but I would need to output from the Arduino to the Teensy and then convert the 0-1023 back to the 0-255. Maybe my understanding of the Modbus is poor or I just need to find a different code source that's easier to use...



  9. #45
    Registered
    Join Date
    May 2015
    Location
    Australia
    Posts
    196
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    I don't really understand modbus at all but if it will only accept single bytes (0-255) and you need two byte integers (0-1023) then just send the high order and low order bytes separately and combine them. In C this can be done automatically by using a union in your data definition. Unions overlay one variable over another one in the same memory location, so you just need to define an int over a char[2] and Bob's your uncle.

    To me, it makes sense for a serial protocol to work in bytes, its up to you to define what those bytes mean.

    Rod Webster
    www.vehiclemods.net.au


  10. #46
    Registered
    Join Date
    Oct 2010
    Location
    USA
    Posts
    313
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    Quote Originally Posted by rodw View Post
    I don't really understand modbus at all but if it will only accept single bytes (0-255) and you need two byte integers (0-1023) then just send the high order and low order bytes separately and combine them. In C this can be done automatically by using a union in your data definition. Unions overlay one variable over another one in the same memory location, so you just need to define an int over a char[2] and Bob's your uncle.

    To me, it makes sense for a serial protocol to work in bytes, its up to you to define what those bytes mean.

    Well the 0-255 value is a limitation of the code running on the Arduino and I haven't found a way to access that other than actually reading the PWM pin with hardware. I did find some libraries that run on an ESP8266 so I'll give that a shot, it looks like it may be a little easier to use.



  11. #47
    Registered
    Join Date
    Oct 2010
    Location
    USA
    Posts
    313
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    So I think I have implemented hysteresis incorrectly. In the current code I am using the hysteresis as an offset basically. If you set the target to 120 and hysteresis at 2, it will toggle the up output once voltage drops below 118 and the down output once voltage rises above 122, 118-122 both outputs are off. After watching a video where someone else was using hysteresis, it seems that I should be turning on the up output once voltage drops below 118 and leave it on until the voltage rises above 120? and the down output will come on at 122 and shut off at 120? In the video I watched they would be turning up on at 118 and off at 122 but at 122 the other output should come on so I think I should switch off at the actual target. Anyone have an idea on how the hysteresis should be built?



  12. #48
    Registered
    Join Date
    May 2015
    Location
    Australia
    Posts
    196
    Downloads
    0
    Uploads
    0

    Default Re: Teensy Up/Down Torch Height Control

    I would have done it the way you have done it as most deadbands I see for PID based controls are implemented
    eg something like:
    Code:
    deadband = 2;
    if(abs(target_volts - actual_volts) > deadband)
      do_adjustment();


    Rod Webster
    www.vehiclemods.net.au


Page 4 of 4 FirstFirst 1234

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Teensy Up/Down Torch Height Control

Teensy Up/Down Torch Height Control