@"Phil Pilgrim (PhiPi)" said:
Or even better and more reliable still, let the 8-bit micro figure out which buttons were pressed and send a serial signal to the Propeller:
Four fewer components, since the micro has internal pull-ups!
-Phil
Used this method for reading 8 DIL switches on spare pins on a micro back in the 80's
I was just wondering one could use two diodes to split the problem in two, lower part count and make space between levels bigger...
But, you'd have to switch back and forth between sourcing and sinking...
But whats the advantage of the external reg vs an internal current source? I think Chip got scared by the current source operation up near the positive rail, but given enough headroom the P2's current sources should be fine for something like this.
I'm planning to use either the 10 or 100uA current source to resolve a slow A/B encoder using similar technique
But whats the advantage of the external reg vs an internal current source?
As you said, headroom. An external source can be driven from a higher voltage. Plus, IIRC, I think Chip was concerned about temperature dependencies in the P2's internal current sources. Anyway, the LM317L is cheap as dirt.
But whats the advantage of the external reg vs an internal current source?
As you said, headroom. An external source can be driven from a higher voltage. Plus, IIRC, I think Chip was concerned about temperature dependencies in the P2's internal current sources. Anyway, the LM317L is cheap as dirt.
-Phil
Phil, what is the weak point of that 5-button scheme that I last posted?
@cgracey said:
Phil, what is the weak point of that 5-button scheme that I last posted?
None, if the buttons are immediately proximal to the Prop. It's the cable that bothers me. Of course, I don't know how long or short it can be. Maybe it's short enough and in an environment bereft enough of noise that it won't be a problem. But, as a general principle, I believe a current interface is more reliable than a voltage interface when distances are a factor. The circuit I illustrated could probably sustain accuracy over a twisted-pair cable hundreds of meters long, assuming a high-enough voltage driving it.
@cgracey said:
Phil, what is the weak point of that 5-button scheme that I last posted?
None, if the buttons are immediately proximal to the Prop. It's the cable that bothers me. Of course, I don't know how long or short it can be. Maybe it's short enough and in an environment bereft enough of noise that it won't be a problem. But, as a general principle, I believe a current interface is more reliable than a voltage interface when distances are a factor. The circuit I illustrated could probably sustain accuracy over a twisted-pair cable hundreds of meters long, assuming a high-enough voltage driving it.
-Phil
I see. Our cable length will be 1-2 meters. The cable impedance will be a thousandth of the resistor impedance. I think noise is the biggest threat. Twisted pair should inhibit noise, though. We will see pretty soon.
I used this resistor chain teamed up with an adc back in the early 90s for vending machines but in another design I also used diodes instead. At low current I got 600mV drop for each diode. The switches shorted a series node to ground.
Thinking on professional audio balancing.
Noice on one wire are opposite to the decoding on the other wire.
A microphone give mVolt, and archive -60dB noice level with shielded cable.
No need to be 600 Ohm.
This is one pin extra on P2
I wonder if all you guys have too much time or are bored due to the COVID lockdown...
Yes, this trick is nice to show what can be done with the smart pins of the P2. It might be used in a real product if somebody runs out of pins and has to read a lot of switches, up to 8 DIP switches for example (if you need more, a matrix would be better). In this case the switches are close to the CPU and we don't have to worry about the resistance of long wires or EMI problems.
If I had to read a lot of pushbuttons (keyboard) over long wires I'd use a separate controller and transfer the data over a serial port.
I wrote "might" and "if" because the probability is rather low now that we have 64 IOs.
@TonyB_ said:
How many cycles will it take to read four or five buttons on one pin?
Six cycles at 5,000 clocks each, with 1mV precision, using short interrupt routines.
30MHz divided by (6 x 5,000) = 1KHz updated rate. Maybe divide that by 8 for 8-unanimous debounce filtering and you get 125Hz transitions. That's at only 30MHz clock rate.
Thinking on professional audio balancing.
Noice on one wire are opposite to the decoding on the other wire.
A microphone give mVolt, and archive -60dB noice level with shielded cable.
No need to be 600 Ohm.
This is one pin extra on P2
Could you draw what that would look like? I can't quite picture it, but I imagine it's pretty simple.
Not that I think this will be implemented, but I just wanted to finish what I started with the current source idea. I wanted to output current in the industrial standard range of 4-20mA. These two circuits do just that, using standard precision resistor values:
Plotting the voltage on the 150R current sense resistor yields the following graph:
Clearly, the parallel topology is the better choice.
Thanks, Phil. That looks pretty good. Current is better than voltage. I was using current from a pin (1mA), but I was not getting linearity. Probably need to try again. BTW, do you check your messages?
@"Phil Pilgrim (PhiPi)" said:
Not that I think this will be implemented, but I just wanted to finish what I started with the current source idea. I wanted to output current in the industrial standard range of 4-20mA. These two circuits do just that, using standard precision resistor values:
Plotting the voltage on the 150R current sense resistor yields the following graph:
Clearly, the parallel topology is the better choice.
@msrobots said:
I think the idea is to do it with a P2 not a second micro.
Mike
True.
But you also have to be careful that it works everywhere, as otherwise you get bad press (which is often worse than no press) because you skimped on the design.
Phil is cautious about the wire length, as am I. Originally I thought it was on the same pcb.
Here is the program that made the 5-button animation.
Ah, you must comment out the QUIT at the end of the REPEAT loop to get the animation to run. If it QUITs, it exits to the code that starts reading the buttons, which is also useful.
@cgracey said:
I see. Our cable length will be 1-2 meters. The cable impedance will be a thousandth of the resistor impedance. I think noise is the biggest threat. Twisted pair should inhibit noise, though. We will see pretty soon.
A challenge here could be initial calibrate of this, especially for volume production ?
With just 27mV step at the mid-region, setting of a 'no-button' point may need to be continual. (That has the risk a pressed/stuck button will skew things.)
One time calibrate, would need to presume the time and temperature ADC drifts were << 27mV. That may be an ask on a P2 ADC ?
What does the P2 data sheet give as worst case drifts ?
@cgracey said:
Using the P2 pin to source 1mA didn't work very well, because the amount of current it sources is somewhat a function of voltage. I was measuring ~850uA at a 0.8V drop from 3.3V, but sourcing all the way to GND drew just over 1mA. This is too non-linear to measure the buttons.
There is also the calibrate of current source to consider.
A quick Spice workup shows current source does have a significant gain, over a series R, as the steps are then nominally identical, and you can use a wider span of the ADC.
( If current is set ~ 80% span, and source feed R is set for max dV, the current source gives a dV improvement of ~ 3.1282x, more that I would have guessed )
If you ran a continual open-button auto-calibrate loop, the current source tolerance and drift would then not matter, and you could tolerate cheaper/more easily sourced resistors. (or, add another button)
100uA may be worth testing, as that is still well above ADC input current and should allow more of the 3v3 span to be used, an ESD series R too.
The combined effects of current source 'bend', and ADC input current will pull the steps away from the theoretical identical sizes, but those effects should be P2 consistent.
Here is some more "alien tech" for you ... I had to step once again into the Wayback machine to my web site where I had posted this for the Basic Stamp .... This thing doesn't even have a micro, just uses a decade counter/divider IC. Whatever frequency you give it translates to the baud in standard 8N1 format
Comments
Used this method for reading 8 DIL switches on spare pins on a micro back in the 80's
I was just wondering one could use two diodes to split the problem in two, lower part count and make space between levels bigger...
But, you'd have to switch back and forth between sourcing and sinking...
If you must do it in analog over a cable, at least make it current-driven instead of voltage-driven:
-Phil
But whats the advantage of the external reg vs an internal current source? I think Chip got scared by the current source operation up near the positive rail, but given enough headroom the P2's current sources should be fine for something like this.
I'm planning to use either the 10 or 100uA current source to resolve a slow A/B encoder using similar technique
As you said, headroom. An external source can be driven from a higher voltage. Plus, IIRC, I think Chip was concerned about temperature dependencies in the P2's internal current sources. Anyway, the LM317L is cheap as dirt.
-Phil
Phil, what is the weak point of that 5-button scheme that I last posted?
None, if the buttons are immediately proximal to the Prop. It's the cable that bothers me. Of course, I don't know how long or short it can be. Maybe it's short enough and in an environment bereft enough of noise that it won't be a problem. But, as a general principle, I believe a current interface is more reliable than a voltage interface when distances are a factor. The circuit I illustrated could probably sustain accuracy over a twisted-pair cable hundreds of meters long, assuming a high-enough voltage driving it.
-Phil
I see. Our cable length will be 1-2 meters. The cable impedance will be a thousandth of the resistor impedance. I think noise is the biggest threat. Twisted pair should inhibit noise, though. We will see pretty soon.
Phil, maybe you could use a P2 setup.
I used this resistor chain teamed up with an adc back in the early 90s for vending machines but in another design I also used diodes instead. At low current I got 600mV drop for each diode. The switches shorted a series node to ground.
Why not use symmetrical mode?
Thinking on professional audio balancing.
Noice on one wire are opposite to the decoding on the other wire.
A microphone give mVolt, and archive -60dB noice level with shielded cable.
No need to be 600 Ohm.
This is one pin extra on P2
How many cycles will it take to read four or five buttons on one pin?
I wonder if all you guys have too much time or are bored due to the COVID lockdown...
Yes, this trick is nice to show what can be done with the smart pins of the P2. It might be used in a real product if somebody runs out of pins and has to read a lot of switches, up to 8 DIP switches for example (if you need more, a matrix would be better). In this case the switches are close to the CPU and we don't have to worry about the resistance of long wires or EMI problems.
If I had to read a lot of pushbuttons (keyboard) over long wires I'd use a separate controller and transfer the data over a serial port.
I wrote "might" and "if" because the probability is rather low now that we have 64 IOs.
Six cycles at 5,000 clocks each, with 1mV precision, using short interrupt routines.
30MHz divided by (6 x 5,000) = 1KHz updated rate. Maybe divide that by 8 for 8-unanimous debounce filtering and you get 125Hz transitions. That's at only 30MHz clock rate.
Could you draw what that would look like? I can't quite picture it, but I imagine it's pretty simple.
Check this out:
https://sites.google.com/site/wayneholder/wayneplexing-buttons
Like charliplexing for buttons...
Oh wait, never mind... only works on one button at a time...
Still, reply #5 here shows 64 switches from 16 inputs:
https://www.eevblog.com/forum/beginners/charlieplexing-switches/
Just need a diode for every switch... This one says can be multiple switches pressed...
Not that I think this will be implemented, but I just wanted to finish what I started with the current source idea. I wanted to output current in the industrial standard range of 4-20mA. These two circuits do just that, using standard precision resistor values:
Plotting the voltage on the 150R current sense resistor yields the following graph:
Clearly, the parallel topology is the better choice.
-Phil
Thanks, Phil. That looks pretty good. Current is better than voltage. I was using current from a pin (1mA), but I was not getting linearity. Probably need to try again. BTW, do you check your messages?
Hey Chip, msg received and responded.
Thx,
-Phil
This parallel one looks nice and linear Phil
Alternately a 10c PADUK micro would do fine too, but of course you have to program it
A regulator is only a few cents.
I think the idea is to do it with a P2 not a second micro.
Mike
True.
But you also have to be careful that it works everywhere, as otherwise you get bad press (which is often worse than no press) because you skimped on the design.
Phil is cautious about the wire length, as am I. Originally I thought it was on the same pcb.
Looks like we can do GIFs in posts now. We need to get monospaced code working, too.
Oh, that's good. I thought it was still weird.
Hey, have you used the new flexible baud feature yet in PNut_v35h?
Here is the program that made the 5-button animation.
Ah, you must comment out the QUIT at the end of the REPEAT loop to get the animation to run. If it QUITs, it exits to the code that starts reading the buttons, which is also useful.
A challenge here could be initial calibrate of this, especially for volume production ?
With just 27mV step at the mid-region, setting of a 'no-button' point may need to be continual. (That has the risk a pressed/stuck button will skew things.)
One time calibrate, would need to presume the time and temperature ADC drifts were << 27mV. That may be an ask on a P2 ADC ?
What does the P2 data sheet give as worst case drifts ?
There is also the calibrate of current source to consider.
A quick Spice workup shows current source does have a significant gain, over a series R, as the steps are then nominally identical, and you can use a wider span of the ADC.
( If current is set ~ 80% span, and source feed R is set for max dV, the current source gives a dV improvement of ~ 3.1282x, more that I would have guessed )
If you ran a continual open-button auto-calibrate loop, the current source tolerance and drift would then not matter, and you could tolerate cheaper/more easily sourced resistors. (or, add another button)
100uA may be worth testing, as that is still well above ADC input current and should allow more of the 3v3 span to be used, an ESD series R too.
The combined effects of current source 'bend', and ADC input current will pull the steps away from the theoretical identical sizes, but those effects should be P2 consistent.
Honda does this on their new Gold Wing to reduce the number of I/O pins needed for all the buttons.
Chip,
Here is some more "alien tech" for you ... I had to step once again into the Wayback machine to my web site where I had posted this for the Basic Stamp .... This thing doesn't even have a micro, just uses a decade counter/divider IC. Whatever frequency you give it translates to the baud in standard 8N1 format