Author Topic: picaxe microcontroller input to parallel port in mach  (Read 2251 times)

0 Members and 1 Guest are viewing this topic.

Offline moorea21

  • Active Member
  • Posts: 228
    • View Profile
picaxe microcontroller input to parallel port in mach
« on: February 14, 2015, 01:19:06 PM »
I need to interface a picaxe microchip with my pmdx122 breakerboard, so it can give a signal to mach to proceed when certain conditions are met (picaxe outputs to mach when an analogue light sensor's output drops by a certain percentage.)

The input pins on the breakerboard measure 2.8V unconnected, and my usual way of triggering them is to ground them using a switch... I have no idea how to trigger an input signal to mach using the picaxe's 5V 20mA output.

I can get mach3 to switch the picaxe on and off in VB script, that's working fine.

Having read the pmdx122 manual, it suggests that the voltage when the data bus buffer is tri-stated is approx 3.2V. I don't actually know quite what that means... apart from the fact that if I just connect the picaxe's output into mach's input, something may get fried?

Anyone done this before, or anything at all similar?

Offline Hood

  • Mach4 Alpha
  • Posts: 25,775
  • Carnoustie, Scotland
    • View Profile
Re: picaxe microcontroller input to parallel port in mach
« Reply #1 on: February 15, 2015, 03:58:18 AM »
Best bet is email Steve Stallings at PMDX, he will give you the best advice.

Hood

Offline moorea21

  • Active Member
  • Posts: 228
    • View Profile
Re: picaxe microcontroller input to parallel port in mach
« Reply #2 on: February 15, 2015, 05:34:33 AM »
I may well do that. I did think maybe I could use the picaxe signal to close a relay and ground the pin, nice and safe, but means building more stuff.

Offline JohnHaine

  • Active Member
  • Posts: 323
    • View Profile
Re: picaxe microcontroller input to parallel port in mach
« Reply #3 on: February 25, 2015, 12:21:24 PM »
Is the power supply voltage to your BoB 5V?  If so, just connect the Pickaxe output to the BoB input.  You want to make sure the data bus is NOT tristated, so its levels are logic high or logic low, not something floating in between.  A relay is not a good way to do this IMHO.  Of course you need to make sure that the BoB pin you're connecting to is an input not an output - inputs don't have a "tristate". 

Offline moorea21

  • Active Member
  • Posts: 228
    • View Profile
Re: picaxe microcontroller input to parallel port in mach
« Reply #4 on: February 25, 2015, 12:35:44 PM »
Thanks, but the output from the picaxe is 5V, and in order to trigger the input pin on the BoB I need to ground it, as far as I understand. Hence using the 5V to energise a relay which closes a switch between input pin and ground on BoB. Unless I'm missing something, which is highly likely.

Offline JohnHaine

  • Active Member
  • Posts: 323
    • View Profile
picaxe microcontroller input to parallel port in mach
« Reply #5 on: February 25, 2015, 06:03:36 PM »
I assumed that you were writing the pick axe code?  Then you just arrange to drive the output pin low to activate rather than high.  If you must use a hardware solution a single transistor inverter is cheaper and smaller than a relay and takes less current.


Sent from my iPad using Tapatalk

Offline moorea21

  • Active Member
  • Posts: 228
    • View Profile
Re: picaxe microcontroller input to parallel port in mach
« Reply #6 on: February 26, 2015, 04:51:07 AM »
I see, I think. So if I'm driving the picaxe pin low, I am basically grounding the input on the BoB , as the picaxe and BoB would share a common ground. If so, that makes a lot more sense than adding a relay. I only really decided on a relay as it isolates the BoB electrically from the picaxe, to reduce any noise etc problems between the 2. I'll try just a transistor, especially as the pin only sources 6uA according to the manufacturer.

Offline JohnHaine

  • Active Member
  • Posts: 323
    • View Profile
Re: picaxe microcontroller input to parallel port in mach
« Reply #7 on: February 26, 2015, 06:13:34 AM »
That's right.

Which pin only sources 6 uA?  That sounds very low for a digital output - in fact it sounds like the tri-state leakage.  The ideal approach would be a direct connection from the Pickaxe output (in enabled mode, not tristate) to the BoB input, with the Pickaxe code modified to drive the output active low.  If you can't change the code, then the (NPN) transistor inverter is an easy approach - probably a 47 K resistor from the output to the base; ground the emitter; connect the collector to the BoB input with a 10 K pullup to +5V.

Offline moorea21

  • Active Member
  • Posts: 228
    • View Profile
Re: picaxe microcontroller input to parallel port in mach
« Reply #8 on: February 26, 2015, 10:32:09 AM »
I'm not at all experienced in these things, rather bumbling my way through it all.

I checked the figure of 6uA;- it's 2mA... and I may have misinterpreted the context too. From Steve Stallings at PMDX:-

"The inputs (pins 11, 12, 13, and 15) of the PMDX-122 need to be driven from a
circuit that can sink 2 milliamperes to ground with the voltage being driven within
0.4 volts of ground."

The code is all up to me.

I think I may be misunderstanding something quite fundamental here, maybe about microprocessors in general, or BoBs, or parallel ports:-

1) If my picaxe is normally outputting 5V INTO the input pin on the BoB, and then it goes low, does that then mean that the picaxe is driving the input pin to 0V? Or does it mean it's left floating? I assumed the latter, as I thought a lack of output from a microprocessor output pin just means it floats around, not tied to 0V.

2) Normally, inputs on my BoB are connected just to switches that act to ground the 5V that my multimeter tells me exists at the input pin. Having trouble getting my head around connecting inputs to anything other than switches; the idea of driving an external voltage into an input pin is a bit alien to me.

If I'm driving 5V into the input, is that input then just held at logic high (5V), or is it held at logic high with 5+5=10V potential? I baulked at the thought of trying that, it sounded like a way to ruin my BoB.

I'd be quite happy to connect the picaxe output (approx 15mA) to the input pin on the BoB and trigger Mach by sending it low; I'd like to understand what I'm doing a bit better before trying it. As I said, I'm probably missing a basic understanding of something here. Hopefully it's not too exasperating to attempt to explain it to me; the effort is certainly appreciated.
« Last Edit: February 26, 2015, 10:37:02 AM by moorea21 »

Offline JohnHaine

  • Active Member
  • Posts: 323
    • View Profile
Re: picaxe microcontroller input to parallel port in mach
« Reply #9 on: February 26, 2015, 12:40:21 PM »
1) If my picaxe is normally outputting 5V INTO the input pin on the BoB, and then it goes low, does that then mean that the picaxe is driving the input pin to 0V? Or does it mean it's left floating? I assumed the latter, as I thought a lack of output from a microprocessor output pin just means it floats around, not tied to 0V.

Yes, the picaxe pulls the input down to 0V, which is what you want.  Provided that a micro o/p pin is not tri-state, it is either at 1 (=5V or whatever the supply voltage is) or near 0 V.

2) Normally, inputs on my BoB are connected just to switches that act to ground the 5V that my multimeter tells me exists at the input pin. Having trouble getting my head around connecting inputs to anything other than switches; the idea of driving an external voltage into an input pin is a bit alien to me.

It's just standard practice.  That's exactly what the parallel port on your PC does, drive voltages from the PC into the BoB.  And the BoB does the same thing back to the PC.

3) If I'm driving 5V into the input, is that input then just held at logic high (5V), or is it held at logic high with 5+5=10V potential?

It's just held at logic high, not at 5+5.