TinyG V8 SS2 pin for vacuum sensing

280 views
Skip to first unread message

Philip Kristoffersen

unread,
Feb 21, 2023, 8:23:05 AM2/21/23
to OpenPnP
Hi there,

Just a quick question since the internet yields me no results. I wanna use the SS2 pin for vacuum sensing, but I cant find if this pin is a 3.3v og 5v pin - so thats my first question.

Secondly, any inputs on this vacuum sensor I have laying around?
MPXV6115VC6U
mkljkljkl.PNG

Cheers,

- Philip

mark maker

unread,
Feb 22, 2023, 8:26:01 AM2/22/23
to ope...@googlegroups.com

Hi Philip.

I'm replying to both questions here, the private email does not seem to work. Also, I think all questions are better asked openly, so others can learn from answers 😉

Answering in reverse, makes more sense:

> Is it possible to get the source code for the 420.21 firmware for the TinyGv8? I am curious and want to try and change some functionality of the board.

Be sure to read this first:

https://makr.zone/tinyg-new-g-code-commands-for-openpnp-use/577/

The source is linked there, but for the ADC we have an issue open, see here:

https://groups.google.com/g/openpnp/c/0tcJh1ygayk/m/PfKPuYG7AgAJ

So if you want to use that, you need to use/start from their version.

I will try and integrate that into my version. Though I would prefer if it was just a minor change, not upgrading all the Atmel Studio environment.

Or better yet to go for an avr-gcc / Cmake build, that Ian has said is possible:

https://groups.google.com/g/openpnp/c/0tcJh1ygayk/m/2OO3ora8AgAJ

@Ian Arkver  any news on that?

> Just a quick question since the internet yields me no results. I wanna use the SS2 pin for vacuum sensing, but I cant find if this pin is a 3.3v og 5v pin - so thats my first question.

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/0ab5b2f4-16c7-435c-a874-95f490c40d9en%40googlegroups.com.

Philip Kristoffersen

unread,
Feb 22, 2023, 8:39:37 AM2/22/23
to OpenPnP
Hey Mark,

Thanks for taking the time to answer :)

Given the Atmega runs 3.3v, I guess my vacuum sensor is out of the question then? Since it sends back a 5v signal (4.5-4.66V to be specific) to be read from the ADC?
Or is there some way I could downstep the signal to a range it can read? Im not a electrical guy :)

- Philip

mark maker

unread,
Feb 22, 2023, 8:41:35 AM2/22/23
to ope...@googlegroups.com

I translated it on my controller (also 3.3V). See the circuit, and further justification for it, presented here:

https://makr.zone/vacuum-sensor/192/

_Mark

Philip Kristoffersen

unread,
Feb 22, 2023, 9:40:00 AM2/22/23
to OpenPnP
Thank you Mark,

Damn, you've sent me down quite the rabbit hole since I have never worked with OpAmps before :D

I have a question, since it is a little confusing for me: Why are you OpAmping twice? Wouldnt you just be able to take the sensor output and divide it with 1k/2k Resistor to a 3.3v threshold and then OpAmp that?

- Philip

mark maker

unread,
Feb 22, 2023, 10:04:30 AM2/22/23
to ope...@googlegroups.com

> Why are you OpAmping twice? Wouldnt you just be able to take the sensor output and divide it with 1k/2k Resistor to a 3.3v threshold and then OpAmp that?

That's actually described on the blog 😁:

I just had a dual op-amp in DIL laying around so I made the first one buffer the sensor output, then used a R/2-to-R resistor divider to shift from 5V to 3.3V, then used the second op-amp to buffer this. The first op-amp is not really needed, if you just have a single op-amp IC (pinout changes!).

I found it a nice (unintenced) side benefit to have the same circuit deliver both a buffered 5V signal and a buffered 3.3V signal, so users could use whatever fits their controller inputs.

_Mark

Philip Kristoffersen

unread,
Feb 22, 2023, 11:01:34 AM2/22/23
to OpenPnP
Hi Mark,

Nevermind, I was overthinking it I guess - I simply downed the signal from 5V to 3.3V with 1k+2k resistor and now it works fine. I'm not very good with the electrical stuff, but I assume you used an OpAmp due to how your motherboard recieved and handled the signal (Capacitors, etc.)? My TinyG V8 seems to take the signal directly into the Atmega, so by simply downing the voltage I've gotten data that I can work with :)

Thanks for the assistance on this,

- Philip

Ian Arkver

unread,
Feb 22, 2023, 12:32:54 PM2/22/23
to OpenPnP
Hi Mark,

Re the avr-gcc and cmake support - I've been discussing it in the PR comments.
Last entry was that Brainstorm was going to test the built hex, perhaps yesterday. Hopefully it worked.

Regards,
Ian

mark maker

unread,
Feb 22, 2023, 1:01:00 PM2/22/23
to ope...@googlegroups.com

Your data sheet says 0.5mA max output, so you should use larger resistance 2k + 4k or more.

And yes, my use of opamp was mostly due to using the unmodified capacitor + pullup thermistor input of the controller. And my sensor could only output 0.1mA max.

_Mark

mark maker

unread,
Feb 22, 2023, 1:07:05 PM2/22/23
to ope...@googlegroups.com

What the... just noticed that I did not receive notifications from GitHub. Will now catch up...

_Mark

Philip Kristoffersen

unread,
Feb 23, 2023, 5:09:05 AM2/23/23
to OpenPnP
Hi Mark,

Why would you want the current to be lower? Like I said, electrical isnt my strong suit, but wouldnt the chip just draw the current it needs from the sensor (in which 0.5mA is max)?
And thank you for taking the time to answer these non-related OpenPnP questions - I apprieciate it a lot :)

- Philip

mark maker

unread,
Feb 23, 2023, 6:03:07 AM2/23/23
to ope...@googlegroups.com

Hi Philip,

the sensor indicates the vacuum level with the voltage on the output. According to the data sheet, it goes up to 4.6V (typ).

Now your resistor divider pulls that to GND, so 4.6V / (1k + 2k) = 1.53mA, i.e. three times too high.

This will hardly "smoke" the sensor, but it will likely lose precision and perhaps stability (i.e. start to oscillate, drift over time etc.). Plus it might age faster.

If you use 3.3k and 6.8k for instance, you get 4.6V / (3.3k + 6.8k) = 0.455mA, i.e. inside the specs.

_Mark

Philip Kristoffersen

unread,
Feb 23, 2023, 6:24:42 AM2/23/23
to OpenPnP
Hi Mark,

Ohms Law, I see :)

Thank you for all the help! I shall return with a TON of questions once I start digging into the firmware stuff.

- Philip

Philip Kristoffersen

unread,
Feb 23, 2023, 8:46:27 AM2/23/23
to OpenPnP
Hey again Mark,

Maybe you can help me with some confusion here:

I have made a voltage divider of 4.7K + 4.7K resistors (its what I had around), reducing the voltage to 2.3V (but meter reads range of 2.4-2.6V) and current to 0.48mA so everything is within spec.
I have set up the actuator as described by the Wiki and it works succesfully .. somewhat, hence my question:

When I turn on the pump and the tubes preasurizes, the voltage drops from the about 2.5V to 1.8V range. All well and good, and I can see the reading from the SS2 is around 2800-2900. However, when the pump is turned off it hits the max value of 4096 and stays there. Do you have any idea why?

With how I've understood raw ADC readings, 4096 / 3.3V = 1241 and therefor shouldnt my readings be somewhere around 600 to 900 range?

- Philip

mark maker

unread,
Feb 23, 2023, 9:14:00 AM2/23/23
to ope...@googlegroups.com

Hey Philip,

erm... I thought the ADC wasn't actually working??

https://github.com/markmaker/TinyG/pull/3#issuecomment-1440962921

> However, when the pump is turned off it hits the max value of 4096 and stays there. Do you have any idea why?

No. Unless you added a capacitor in parallel to the upper resistor.

You should actually add a capacitor in parallel to the lower resistor. It smooths the signal and protects the IO pin against spikes/discharges. The larger the cap the slower the signal follows, but the more stability you get.

[sensor]--- long distance ---=---[ R ]---o-----o-----SS2
   |                            upper    |     |
   |                                    |R|   _C__
   |                               lower| |   ____
   |                                     |     |
  -o-------------------------------------o-----o-----GND

> With how I've understood raw ADC readings, 4096 / 3.3V = 1241 and therefor shouldnt my readings be somewhere around 600 to 900 range?

Can't follow you there.

1.8V*1241 = 2234

_Mark

Philip Kristoffersen

unread,
Feb 23, 2023, 9:29:56 AM2/23/23
to OpenPnP
Hi Mark,

ADC reading seems to be working for me? :)

As described, I get readings just fine when the pump is on - I'm just not sure why it goes outside the 12bit range when its off, when as far as I can calculate, it shouldnt.
Also, it is wired with the capacitor as you have so nicely described, so no issues there either.

- Philip

Ian Arkver

unread,
Feb 23, 2023, 1:51:28 PM2/23/23
to OpenPnP
The XMEGA has 4 possible ADC reference voltages (see section 25.5 of the XMEGA Manual). These are

* Internal 1.0V ref
* VCC/1.6
* AREF PORT A
* AREF PORT B

The internal 1.0 is the default value after reset, and neither of the AREF pins are connected. The library code for the ADC sets it to VCC/1.6 instead.

    /* Set reference voltage on ADC to be VCC/1.6 V.*/

   ADC_Reference_Config(&ADCB, ADC_REFSEL_VCC_gc);

An input voltage the same as this reference should result in the full-scale reading.

VCC is 3.3V which means the full scale reference voltage is about 2.0625V. Anything over this will probably read as 4095. Anything over 3.3V-ish will be clamped by ESD protection diodes to the VCC rails (and may damage the chip).

Regards,
Ian

mark maker

unread,
Feb 24, 2023, 1:47:15 AM2/24/23
to ope...@googlegroups.com

Of course!

While we're at cleaning that up, should we change it back to the default? I assume using the internal ref is more consistent, right?

_Mark

Ian Arkver

unread,
Feb 24, 2023, 4:06:07 AM2/24/23
to OpenPnP
Could do but it would change the values reported for anyone already using it (only the 3 of you?). You'd need to change your external R divider to match the 1.0V full scale.

Yeah, the bandgap reference would be more accurate than VCC/1.6 probably, but you've halved your signal range so any noise being picked up on PORTB.3 might be more significant.

There are other specs which might influence that - eg. offset voltage, impedance of the input, bias current, etc. Typically ADC inputs like a low impedance source so are usually buffered. You've a high impedance R divider input.

Regards,
Ian

Philip Kristoffersen

unread,
Feb 24, 2023, 4:42:44 AM2/24/23
to OpenPnP
Thanks for clarifying Ian!

May I ask which manual you are refering to? I have the ATxmega192A3 open, but doesnt seem to correlate with what you are reffering to?

- Philip

mark maker

unread,
Feb 24, 2023, 4:46:03 AM2/24/23
to ope...@googlegroups.com

> but it would change the values reported for anyone already using it

I'm actually very confused about that.

When I made the ADC version, I believe I simply tested it using VCC and GND. And there was a user wanting it, and saying he'll test it, but never reporting back. Then Roman said it doesn't work, he got the 100Hz pulse on the pin. Then Philip said it, it does work and he gets a readings, albeit not taking the VCC/1.6 range into account.

So maybe the 100Hz is some config option set wrong?

From what I know positively, nobody actually uses it yet, not as an established solution.

Regarding the ref voltage, analog supply (AVcc) is just connected to Vcc here:

So a matter of how noisy the VCC regulator is, given the input side PSU noise (motors!) and output side load changes (no idea), plus drift over time and temperature. The regulator U7 is not specified here:

https://github.com/synthetos/TinyG/blob/master/hardware/v8schematics/v8h/tinyGv8h%20-%20schematic%20page2.pdf

But I think I can read LM2594 off the IC:

https://www.ti.com/lit/gpn/lm2594

Quarter century old design and titled "simple".

Maybe not as good as the internal ref, even with half the signal range. 😉

_Mark

Philip Kristoffersen

unread,
Feb 24, 2023, 5:09:15 AM2/24/23
to OpenPnP
Yeah, I've had the oscilloscope hooked up to SS2 and GND to follow what was happening and I get a pretty clean signal. So everything seems to be working perfectly fine for me when you take the VCC/1.6V into consideration of my results.
I dont need to know the high range, 4096 will do fine, so given I am staying under 3.3V I think I will just leave it as is for now.

And I will be using this functionality for the machine, however, things may change since we are considering just making a new board. Most things from the TinyGV8 will be moved over, but changing the drivers, opening up for more IO pins, adding 5V supply, etc. Just to take full advantage of the ATxmega and removing some of the unnecessary IOs.

So it seems to work fine? Maybe that one person with an issue is solely bad hardware / unknown interference?

- Philip

Philip Kristoffersen

unread,
Feb 24, 2023, 8:24:10 AM2/24/23
to OpenPnP
Hi Mark,

I was looking around a bit for the firmware you made and it did take a while. Is there any reason why https://github.com/markmaker/TinyG isnt linked at the bottom of https://makr.zone/tinyg-new-g-code-commands-for-openpnp-use/577/ with all the other links?

It is a minor detail, but I didnt realize at all that the link for the git was in the middle of the text :)

Also, regarding questions for firmware stuff, should I just make a new post? Given the title on this one is not accurate for that at all?

- Philip

Ian Arkver

unread,
Feb 24, 2023, 9:15:31 AM2/24/23
to OpenPnP

AVCC is the supply for the analog circuitry. The two AREF pins are PA.0 and PB.0.

mark maker

unread,
Feb 24, 2023, 1:32:06 PM2/24/23
to ope...@googlegroups.com

Hi Philip

> Is there any reason why https://github.com/markmaker/TinyG isnt linked at the bottom of https://makr.zone/tinyg-new-g-code-commands-for-openpnp-use/577/ with all the other links?

Good point, thanks. Done.

_Mark

mark maker

unread,
Feb 24, 2023, 1:35:35 PM2/24/23
to ope...@googlegroups.com

> Also, regarding questions for firmware stuff, should I just make a new post? Given the title on this one is not accurate for that at all?

New post, thanks.

_Mark

kumme

unread,
Feb 26, 2023, 1:10:00 PM2/26/23
to OpenPnP
Hi Everyone,

I'm new to the forum. I set up a Liteplacer with OpenPnP about a year ago. I like all the goodies which were contributed, it helps me a lot.

> but it would change the values reported for anyone already using it

I'm actually very confused about that.

When I made the ADC version, I believe I simply tested it using VCC and GND. And there was a user wanting it, and saying he'll test it, but never reporting back. Then Roman said it doesn't work, he got the 100Hz pulse on the pin. Then Philip said it, it does work and he gets a readings, albeit not taking the VCC/1.6 range into account.

So maybe the 100Hz is some config option set wrong?

From what I know positively, nobody actually uses it yet, not as an established solution.



I use the vacuum sensing since months and I can confirm that there is no periodically 100 Hz pulse detectable on the SS2 pin not with sensor connected and not with sensor unconnected. I use Marks amplifier circuit.

But, there is lots of noise when the steppers are enabled. I measure here 500 mVpp but can not identify if it is radiation the probe detects or real signal.

In my setup the values read from the ADC are easily jumping 50 digits but it does not matter because the threshold is big enough.

I think the TinyG is not really made for analog measurements. There are no blocking capacitors at the VCC Pins. Especially the AVCC needs blocking capacitors, better with an inductance in series. The SS2 pin is connected to the controller without protection and without blocking capacitor. I think at least the blocking capacitor is mandatory. 

Using the VCC as reference should be fine. It is regulated and filtered and precision is not what we should be looking for.

Some ideas to improve the TinyG (untested for the moment):
- 0402 capacitor with 10nF between AVCC (pin 61) and and GND (pin 60) or at a better location.
- Capacitor with 10nF at the pinhead connector between SS2 and GND

I have some software related questions with vacuum sensing and will start a separate thread.

BR
Klaus




 

mark maker

unread,
Feb 26, 2023, 2:00:27 PM2/26/23
to ope...@googlegroups.com

Hi kumme,

> use the vacuum sensing since months and I can confirm that there is no periodically 100 Hz pulse detectable on the SS2 pin not with sensor connected and not with sensor unconnected. I use Marks amplifier circuit.

Thanks for the clarification. This makes it more likely that some of the many $$ setting in TinyG actually enabled the 100Hz signal for Roman.

I may not understand correctly, but the following seems contradictory:

> I think the TinyG is not really made for analog measurements. There are no blocking capacitors at the VCC Pins. Especially the AVCC needs blocking capacitors, better with an inductance in series.

... contradicts ...

> Using the VCC as reference should be fine. It is regulated and filtered and precision is not what we should be looking for.

.. as the two are directly connected on a TinyG.

> 0402 capacitor with 10nF between AVCC (pin 61) and and GND (pin 60) or at a better location.

I agree, but hard to do on an existing PCB, right?

> Capacitor with 10nF at the pinhead connector between SS2 and GND

Didn't we always say you need a capacitor? It is even on the picture:

https://makr.zone/tinyg-new-g-code-commands-for-openpnp-use/577/

_Mark

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.

Ian Arkver

unread,
Feb 26, 2023, 2:46:22 PM2/26/23
to OpenPnP
I suspect Roman's issue may be with some of the external stuff he has on his sensor board, but dunno for sure.

Decoup on AVCC would help with noise on the supply for analog parts of the SoC. As Klaus says a ferrite bead to isolate it from regular VCC would have been nice too. But yeah, there's noise on the reference, noise on the signal pin and noise on the internal power domain. None of which is ideal.

You/TheReza suggested a 1uF cap on the sensor input, which seems a lot to me. Klaus is suggesting 10nF which should provide some RF filtering while not adversely affecting the rate of signal change too much.

Using a well screened cable between the TinyG and the sensor would also help.

Just a few thoughts.
Regards,
Ian

mark maker

unread,
Feb 27, 2023, 1:36:58 AM2/27/23
to ope...@googlegroups.com

> You/TheReza suggested a 1uF cap on the sensor input, which seems a lot to me. Klaus is suggesting 10nF which should provide some RF filtering while not adversely affecting the rate of signal change too much.

I agree, I felt the same way, but was not confident to overrule TheReza's judgement, as the cap also protects the input, and my knowledge there is very limited.

_Mark

Philip Kristoffersen

unread,
Feb 27, 2023, 6:09:04 AM2/27/23
to OpenPnP
Hi again,

I thought I had mentioned this tiny detail, so I went through my posts and realized I didnt! So I thought I might add it just in case it will have relevance for someone:
I have used a 0.1uF cap for my board - not the 1uF cap as described on the wiki.

- Philip

Klaus

unread,
Feb 27, 2023, 7:06:26 AM2/27/23
to OpenPnP
Hi,

I may not understand correctly, but the following seems contradictory:

> I think the TinyG is not really made for analog measurements. There are no blocking capacitors at the VCC Pins. Especially the AVCC needs blocking capacitors, better with an inductance in series.

... contradicts ...

> Using the VCC as reference should be fine. It is regulated and filtered and precision is not what we should be looking for.

.. as the two are directly connected on a TinyG.


I meant that in the case of accepting lower accuracy e.g. created by noise, using VCC is fine since all other solutions (e.g. ext. reference) would need a different design
Using the bandgap as reference has in my eyes the problem that the signal must be scaled down to max. 1V and it would be more prone to noise.

At least the 3V3 are regulated by U7 and filtered, but the AVCC is still connected to the same 3V3 rail to which the digital signals are connected to. Not ideal but tolerable considering accuracy aspects.

 > 0402 capacitor with 10nF between AVCC (pin 61) and and GND (pin 60) or at a better location.

I agree, but hard to do on an existing PCB, right?


It is the only feasible improvement regarding supply voltage I see, the pins are next to each other. Great exercise with the air gun ;-)

> Capacitor with 10nF at the pinhead connector between SS2 and GND

Didn't we always say you need a capacitor? It is even on the picture:


When I installed up the vacuum sensor I did not check the TinyG schematic but installed the 1µF as you show. I was thinking that the 1µF plus the 470R output resistor were a necessary low pass filter for some reason. Since the solution is working properly I didn't care. Now when I checked the schematic I saw that the typical 1 - 10 nF decoupling capacitor is missing.

1µF || 10nF would be good. The 1µF for minimum ESD protection, the 10nF for filtering.
 




mark maker

unread,
Feb 27, 2023, 8:07:52 AM2/27/23
to ope...@googlegroups.com

> Using the bandgap as reference has in my eyes the problem that the signal must be scaled down to max. 1V and it would be more prone to noise.

I would assume that this noise would be much smaller, especially if you were to add the top divider R on the TinyG side to SS2, and then lower divider R || 1µF || 10nF to GND.

This could also keep the input voltage level at 3.3V (or 5V) for whatever sensor is on the other side.

As the input is then also protected by top divider R, the caps could be lower value, I guess.

_Mark

Klaus

unread,
Feb 27, 2023, 12:49:00 PM2/27/23
to OpenPnP
On 2/27/23 16:02, Klaus wrote:

I would assume that this noise would be much smaller, especially if you were to add the top divider R on the TinyG side to SS2, and then lower divider R || 1µF || 10nF to GND.

I'm not sure about this.

I did some tests today with a 10nF cap at AVCC and SS2. No improvement. Actually the approx. 40 digits mean about +/- 10mV. I can accept this but I'm always looking for improvements. In the end the sensor itself will also not give a static signal and the the vacuum of the cheap pump is also not perfectly stable.

Mark, what dynamic range do you measure at the SS2 pin? Does the voltage go down to nearly 0V and up to 2V?

In my setup I measure approx. 2V without vacuum and 1V with maximum vacuum what means I'm currently wasting about half of the dynamic of the ADC. I have to recalculate the amplifier resistors and remove the offset voltage.
 
BR
Klaus

mark maker

unread,
Feb 27, 2023, 1:39:53 PM2/27/23
to ope...@googlegroups.com

> Mark, what dynamic range do you measure at the SS2 pin? Does the voltage go down to nearly 0V and up to 2V?

I don't use the TinyG on my machine. I just have if on a testing rig, so I can test new OpenPnP developments against it. But it just drives one stepper...

My real machine has a Smoothie clone and the sensor is on a thermistor input.

https://makr.zone/tag/vacuum-sensing/

> In my setup I measure approx. 2V without vacuum and 1V with maximum vacuum what means I'm currently wasting about half of the dynamic of the ADC. I have to recalculate the amplifier resistors and remove the offset voltage.

As you said, "the the vacuum of the cheap pump is also not perfectly stable"...

Frankly, I found the vacuum sensing only works for the larger nozzle tips, as they have large losses when there is no part on the nozzle tip, and those can be detected.

For the finest tip it doesn't really work. The pump pressure fluctuates all over the place, and even the short time Difference method will not work the next time you run the machine.

I believe these fluctuations are really in the vacuum pressure, not in the measurements. The seal of the part against the nozzle tip varies, the pump performance itself varies, the temperature seems to matter, even the different quenching of the tube through the drag chain might be a factor.

So I think you have enough dynamic range for what you can reasonably expect to measure.

_Mark

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages