TinyG connection to SuperPID

Discussion of tinyG control platform
semperfikurt
Posts: 12
Joined: Wed Nov 05, 2014 3:08 pm

Re: TinyG connection to SuperPID

Post by semperfikurt » Mon May 18, 2015 8:55 pm

yeah the 3.3V vs. 5V PWM was something I was wondering about that it might be causing the rpm issues. I was looking at trying to buffer the PWM up to 5V but couldn't figure it out, how exactly do I do this?

rtlflatt
Posts: 178
Joined: Sun Jan 18, 2015 2:11 am
Location: Bay Area, CA

Re: TinyG connection to SuperPID

Post by rtlflatt » Tue May 19, 2015 2:05 am

relay with an outside 5v source? or transistor? not sure how those methods would be affected by a pwm pulse tho. im sure any moment now cvoinescu will pop up with the answers you seek lol. cvoinescuuuuu
Shapeoko 3 #??? (Missing serial plate?)
Lulzbot Taz 5 (Heavily modified)

cmcgrath5035
Posts: 61
Joined: Thu Oct 31, 2013 6:56 pm
Location: Florida, USA

Re: TinyG connection to SuperPID

Post by cmcgrath5035 » Tue May 19, 2015 10:36 pm

I do suggest you read the doc I referenced.
The third line is how I do it: "tinyG PWMout 3.3V logic buffered to 5V with external 74AHCT125 driver".
That is one of many ways; for sure I would not recommend a relay
ShapeOko (V1) SN 1462
Dual 820mm Y, Double X, ACMEZ. V2 Motor Plates
TinyG V7 Controller; DUE and tinyGV9 test bed for tinyG2

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: TinyG connection to SuperPID

Post by cvoinescu » Wed May 20, 2015 2:30 am

Sorry, I don't have a SuperPID to test, and my TinyG is still packed in a box somewhere. I am a little surprised that the SuperPID input is not 3.3 V compatible. But the 74AHCT125 sounds like a good idea -- in fact, many 74HCT and 74AHCT series ICs can be used as 3.3 V to 5 V level translators, including 74HCT00, 74HCT04 and 74HCT14.

A relay will not work.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

semperfikurt
Posts: 12
Joined: Wed Nov 05, 2014 3:08 pm

Re: TinyG connection to SuperPID

Post by semperfikurt » Wed May 20, 2015 2:56 am

I pulled out the multimeter and did some tinkering and figured out the reason there was no RPM control, was that in order to turn the router on, I had to use the M5 command because of the spindle pinout power state. Thus tinyg always thought it was turned off... thus no PWM control voltage. Once I wired up a hard switch, I had rpm control again through gcode, but again, it was not correct. Is this a matter of configuration of the phase low and phase high? or is this as a result of the voltage differential?

I definitely will be checking out that page on buffering, I sure appreciate the help!

As for the Spindle pinout....any thoughts on how to invert that so it is compatible with the SuperPID "run" input?

cmcgrath5035
Posts: 61
Joined: Thu Oct 31, 2013 6:56 pm
Location: Florida, USA

Re: TinyG connection to SuperPID

Post by cmcgrath5035 » Wed May 20, 2015 11:02 am

Reminder:, Like cvoinescu , I have never touched a SuperPID, all my comments are based on the product.pdf, specifically page 23, just reading the words and looking at the schematic.

FYI, I don't understand what you ,mean when you write: "I had to use the M5 command because of the spindle pinout power state".

In Gcode, an M3 S10000 says turn on the spindle at 10000 rpm, an M5 turns spindle off

SuperPID is really a voltage controlled speed controller, not a PWM controller that changes (DC) motor speed by feeding the motor pulses of current.
But the SuperPID design accommodates controllers (like tinyG) that only 'speak' PWM for variable speed, by converting the variable duty cycle PWM pulses into a DC control voltage in the 0-5V range.
SuperPID is also different from the PWM controllers I have seen, in that it has both the 'Run' (really on/off) and PWM inputs.
A typical PWM controller uses just the PWM phase(ON pulse width) to decide what to output to the motor.

TinyG has two output pins that are useful here, SPIN and PWM

When you send an M3 S10000 command, tinyG sets SPIN to LogicHigh(3.3v) and PWM outputs 3.3v PWM waveform whose phase corresponds to 10000 rpm phase value set up in the $p1parameters
When you send M5 command, SPIN will be logic low (0v) and PWM will be whatever phase is set in parameter $p1pof, the "off phase"

To meet the interface specification for SuperPID , which calls for 5v logic, your need to buffer both SPIN and PWM from 3.3vlogic to 5v logic.
Then connect SPIN(buffered) to RUN and and tinyG_PWM to SuperPID_PWM.
And YES, YOU MUST CALIBRATE tinyG $p1* parameters to what works for your SuperPID.
I can almost guarantee you that the default tinyG parameters will not work.
You can start with these (guesses on my part):
[p1frq] pwm frequency 1000 Hz
[p1csl] pwm cw speed lo 5000 RPM (or whatever you believe is the min rpm of your spindle)
[p1csh] pwm cw speed hi 33000 RPM (or whatever you believe is the max rpm of your spindle)
[p1cpl] pwm cw phase lo 0.1 [0..1] (a guess, this needs to be experimentally verified)
[p1cph] pwm cw phase hi 1.0 [0..1] (a better guess - since 100% duty cycle should map to max control voltage)
[p1wsl] pwm ccw speed lo 1000 RPM (does not matter, M3 command is cw rotation)
[p1wsh] pwm ccw speed hi 2000 RPM (d (does not matter, M3 command is cw rotation)oes not matter, M3 command is cw rotation)
[p1wpl] pwm ccw phase lo 0.125 [0..1] (does not matter, M3 command is cw rotation)
[p1wph] pwm ccw phase hi 0.200 [0..1] (does not matter, M3 command is cw rotation)
[p1pof] pwm phase off 0.000 [0..1]

I suggest you reset tinyG after entering $p1* parameter changes and before connecting to your SuperPID

Side note: You can use your manual switch to toggle SuperPID Run lead, then just have the rpms follow the PWM specified control voltage. I don't recommend it, because you will find that your SuperPID might output a burst of RPM from your spindle when tinyG is started (powered up) or reset. The SPIN lead will help filter that out, but do experiment with transient behavior.

Another side note: 3.3V vs 5V logic. As cvoinescu comments, the need to do the logic buffering is "maybe". For sure, tinyG only outputs 3.3v logic high, and can source enough current to turn on an led (the input to an opto-isolator). And, the SuperPID interface spec says 5V input. That said, the 3.3v tinyG signals might be enough to activate the RUN and PWM inputs, at least for quick test. It has been my experience that most '5v rated' opto isolator inputs operate with 3.3v inputs, but are frequently marginal (not ON, just sort-of-ON), it depends on the gain of the internal phototransistor that reacts to the led, inside the opto-isolator. I would not recommend going into 'production' with that interface unbuffered, but a quick bench test might work.
ShapeOko (V1) SN 1462
Dual 820mm Y, Double X, ACMEZ. V2 Motor Plates
TinyG V7 Controller; DUE and tinyGV9 test bed for tinyG2

semperfikurt
Posts: 12
Joined: Wed Nov 05, 2014 3:08 pm

Re: TinyG connection to SuperPID

Post by semperfikurt » Wed May 20, 2015 2:22 pm

cmcgrath5035 wrote:FYI, I don't understand what you ,mean when you write: "I had to use the M5 command because of the spindle pinout power state".

In Gcode, an M3 S10000 says turn on the spindle at 10000 rpm, an M5 turns spindle off
On the TinyG, the "spin" terminal outputs 3.3V when you turn the spindle on (M3), and 0V when you turn the spindle off (M5). The SuperPID however, is reversed; the "run" input terminal turns the spindle on when voltage is at 0, and off when it is at 5V (I have been using the 3.3V from the TinyG and it's responding to these commands okay though, albeit reversed). Thus one of the issues I am trying to figure out here is how to invert the power state for this connection from normally closed to normally open. Now originally I was toying with the idea of just using the inverted M3/M5 commands and making-do with it however, when I enter M5 (the router turns on), but as far as the TinyG is concerned I just turned it off... thus the PWM terminal doesn't output a signal

In order to fix this what would you think is the best solution? is there a software configuration I can change? or is this going to need to be a hardware solution? My knee jerk thought was that an electrically thrown switch would do this: wire the switch to the SuperPID just like a normal on/off switch, and then hook the throw control to the spin output... essentially make the spin output control an electrical NO switch, as opposed to controlling the run inport directly. thoughts?
cmcgrath5035 wrote:Side note: You can use your manual switch to toggle SuperPID Run lead, then just have the rpms follow the PWM specified control voltage. I don't recommend it, because you will find that your SuperPID might output a burst of RPM from your spindle when tinyG is started (powered up) or reset. The SPIN lead will help filter that out, but do experiment with transient behavior.
I did notice transient behavior with this physical switch setup. At first it worked like a charm, and I had total rpm control, and I got the PWM settings almost dialed in (by adjusting the phase low and phase high for the PWM output), but then it started running at full blast every time I turned the router on with the physical switch. When it did this everything quit working, no chilipeppr commands at all, I had to turn the router off to regain control of anything. So you are definitely right on that.

I have gone through just about every page google has a link to on this subject (tinyg Wiki as well), and wired everything up per the manufacturer instructions PDF (page 23). Everything just says "buffer the pwm to 5V" but nothing explains exactly how to do this.

Is buffering the PWM and SPIN outputs to 5v a software or hardware thing? how exactly do I accomplish this?

semperfikurt
Posts: 12
Joined: Wed Nov 05, 2014 3:08 pm

Re: TinyG connection to SuperPID

Post by semperfikurt » Wed May 20, 2015 2:35 pm

actually I just looked and saw that you specified the hardware you used in your document to buffer the 3.3V output (74AHCT125 driver). How did you wire all this up?

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: TinyG connection to SuperPID

Post by cvoinescu » Wed May 20, 2015 3:57 pm

If you use 74HCT00, 74HCT04 or 74HCT14 instead of the 74HCT125 (or the AHCT versions), you can use a spare gate to invert the spindle enable signal.

For instance, using the 74HCT04:
PWM output from TinyG to pin 1
Pin 2 to Pin 3
Pin 4 to PWM input on the SuperPID
Spindle enable output from TinyG to pin 5
Pin 6 to spindle enable input on the SuperPID
Pin 7 to GND
Pins 9, 11, 13 also to GND*
Pins 8, 10, 12 not connected*
Pin 14 to +5 V
Ideally, a 100 nF capacitor between +5 V and GND somewhere near the IC
Note that SuperPID GND and TinyG GND are connected.

The same pinout works for 74HCT14. Let me know if you need it for the 74HCT00.

* These are three spare inverters. Their inputs must not be left unconnected. You can use them to level-shift another three signals while also inverting them, or level-shift one inverted and one non-inverted signal.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

cmcgrath5035
Posts: 61
Joined: Thu Oct 31, 2013 6:56 pm
Location: Florida, USA

Re: TinyG connection to SuperPID

Post by cmcgrath5035 » Thu May 21, 2015 1:58 am

Oops, sorry, missed the inverted (active low) for run.

You asked how I wired mine - I was going the quick a easy route, perfboard, a dip socket and soldering iron.

The job can be done with individual transistors too.

It would seem cvoinescu has provided a number of options, so let us know how you make out.
ShapeOko (V1) SN 1462
Dual 820mm Y, Double X, ACMEZ. V2 Motor Plates
TinyG V7 Controller; DUE and tinyGV9 test bed for tinyG2

Post Reply