584,854 active members*
4,310 visitors online*
Register for free
Login
Page 3 of 3 123
Results 41 to 48 of 48
  1. #41
    Join Date
    May 2015
    Posts
    684

    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

  2. #42
    Join Date
    Oct 2010
    Posts
    317

    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.

  3. #43
    Join Date
    Oct 2010
    Posts
    317

    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.

  4. #44
    Join Date
    Oct 2010
    Posts
    317

    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...

  5. #45
    Join Date
    May 2015
    Posts
    684

    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

  6. #46
    Join Date
    Oct 2010
    Posts
    317

    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.

  7. #47
    Join Date
    Oct 2010
    Posts
    317

    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?

  8. #48
    Join Date
    May 2015
    Posts
    684

    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 3 of 3 123

Similar Threads

  1. Torch height control
    By drieslaas in forum CNC Plasma / Oxy Fuel Cutting Machines
    Replies: 5
    Last Post: 05-11-2015, 04:13 PM
  2. Torch height control
    By Bobnire in forum Waterjet General Topics
    Replies: 3
    Last Post: 12-16-2012, 10:48 AM
  3. Torch Height Control
    By Rxe in forum Waterjet General Topics
    Replies: 7
    Last Post: 04-07-2010, 12:09 PM
  4. Torch Height Control
    By luther in forum Plasma, EDM / Other similar machine Project Log
    Replies: 4
    Last Post: 07-12-2007, 09:51 PM
  5. Torch Height Control / Capacitive Height Control
    By ahlbebuck in forum Open Source Controller Boards
    Replies: 0
    Last Post: 11-27-2006, 08:32 PM

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
  •