Sending bits to prop with mechanical switches, easiest cheapest way?
rwgast_logicdesign
Posts: 1,464
Ok so you got 8, 16, 32 switches maybe. You want to send the state of these switches to the prop, whats the best way. Obviously you could use eight data pins but thats not elegant or intuitive at all. Id like to send the bytes via i2c or 1 wire bus. I thought ok you could use a cheapy 8 bit micro and connect to its 8 pins then send the data off to the prop, but that seems like over kill. Basically I just wanna hit some push buttons or flip some switches into a binary pattern then hit a send button and off to the prop the byte goes to be stored in memory or sd or whatever.... Id like to do this as cheap as possible and maybe even without an IC, maybe just passive and transistors, but if the IC route is cheaper so be it...
Comments
-Phil
You could use an I2C I/O expander. The PCA9554 provides 8 I/O bits while the PCA9555 provides 16 I/O bits. In both cases, the I2C bus could be the same 2 I/O pins as are used for the boot EEPROM. In both cases, the I2C address is selectable, so you could have up to 8 such devices on the same I2C bus.
?? - Simplicity has its own elegance.
If the pins are not doing anything else this can work fine.
The cheapest is likely to use a series of HC4051's, ( ~ 13c? ) as that allows you to use just one load resistor.
4 of these will scan 32 contacts, using 7 pins, and 9 can scan 64 contacts using 7 pins.
But a 74HC165 parallel-in serial-out shift register or a handfull multiplexer chips like 74HC152 added
to your host Prop would do. Multiplexers take a few address bits and select a single input based on the address.
So the software to read switches through one is fairly straight forward.
Set the address of the switch you want to read (for a single mux chip that means 3 output pins) and read the
input that the mux output is wired to. '152 is not expandable, so it works well up to 8 inputs.
So it would have to have it's OUTPUT fed into one of another '152's INPUT (as an expander) and another
address line (or 3) for THAT chip to select one of 8 mux chips. Now we are looking at 8 x 8 or 64 maximum
switch (or just bit) inputs).
It's a lot faster since you can address any desired switch without having to shift in all the ones befor that one.
http://html.alldatasheet.com/html-pdf/63830/HITACHI/HD74HC152/501/2/HD74HC152.html
Don't forget the knob.
But in reality this is going to hopefully be commercial project, that is why im concerned about price, every penny counts id rather splurge on things that will benefit the whole system rather than things that are not speed critical. Im still learning about hardware, reading tons of books listening to pod casts all day I love it I really want to get into this industry I could do this stuff 16 hours a day. Money and having to read are the only things slowing me down !
Ok so this is going to be used as an education tool. Im going to sell it has a kit, and Im going to document how it works along with how to build it. Im no electronics guru but the goal of my project is to teach people how computer and machine code work so as long as I understand how it works and can explain what I built thats enough to satisfy what Im trying to do. Here is the project
http://forums.parallax.com/showthread.php?139417-The-binary-programmable-Interface-based-on-a-prop-quot-70s-wire-wrap-micro-throw-back-quot-.&p=1090687#post1090687
Now im going to look into the PCA chip figure out how it works and what its cost is, hell maybe I can get a sample. My idea is to drop a TI MSP430 dip between the prop and the buttons. The things are a buck they have built in flash and will communicate with i2c or anything else for that matter. My problem with that is this is an educational thing and Im trying to keep it simple, ya throwing a micro at a problem is a simple cheap solution and cost effective. But is it fun for the kit builder, will it teach them anything to solider on a micro that i explain i programmed to do this... no. This is my worry about the PCA chip too. Now this kit is suppose to be low level enough so kids/hobbyist understand whats going on and how hardware and bits acually make a computer do what it does, but not so level its just to overwhelming like it would be for most beginners like myself to wire wrap a z80 schematic.
So based on trying to keep the board cheap, and trying to teach CS not just kit soldering what would you suggest? The 74s may be the way to go... idk whatever you guys think would meet my goal im going to have to go book up on it too probably, unless its a push button and pull down resistor connected to each pin!! Im still not even real sure how the whole thing will work I mean if i send PASM opcodes with switches i guess ill need 32 switches, but im hoping to do an intel 8088 emulator or something and keep it 8 bit. Its prop based once you learn the basics of ASM you can always hook up a kb and monitor and write some PASM. I will probably use 7 segment led's to show register values out put program data. This is a no kb or monitor deal.
Would going with some kind of transistor/passive solution be to complex and exspensive? I wanted to go that way really but maybe thats like hitting the z800 schematic wall. And if there is a way to do it with those kinds of components and keep the prop pin count down by half the bits at least id need some part names and a lil explanation of what to do with them. This is what im sayin though i could add a micro and its all software, and for the consumer its just soldering a programmed micro,,,
1) are there really that many people now days that want to know how a computer and machine level code really work?
2) As far as a target processor for learning these basics, I would think you would want a very simple architecture with a simple instruction execution cycle and a flat memory space. Either an 8080 type model or a 6502 or 6800. When you get into the 8088/8086, you get into memory banks and all kinds of nasty sophisticated hardware architecture - much more than the basics. The Propeller itself has a unique architecture with complications added from the multi-cog structure and the dedicated and shared memory spaces. There are either no registers are nothing but registers in the COG memory space. It's a very sophisticated processor for a beginner to grasp the machine level operations....the expert are still learning and squeezing tricks out of it.
3) If someone is really interested in the basics and how the machine works at the bit level and byte, there is an absolutely WONDERFUL book called CODE by Charles Petzold that literally goes from information encoding systems (Morse, Braille, etc.), and then how binary fits into this and then once you have binary, how you begin to manipulate bits and how the logic gates work and how they are combined into adders and ones and twos compliment math and clocking and memory addressing and latching and instructions fetching and decoding and.......well, you get the picture. I read this on a trip to Atlanta last spring and literally couldn't put it down. Maybe an "Experimenters Kit" or "lab Environment" to compliment this book? You could implement it in hardware (switches and logic chips) and software (logic simulators, adders, etc.) and folks could learn and play at a very basic level....at some point, you could load up the 8080 emulator in a COG and they could program and debug an 8080.
Propeller PASM is difficult to teach to beginners (there are a number of threads proving this fact). If you have programmed some processor in some assembler before, it is much easier, if you have programmed the Propeller in SPIN, it is much easier but if you are really a beginner, coding in PASM is not going to come to most people. I think to understand the various layers of hardware and software abstraction from where most programmers are today down to the machine level requires a foundation to be built up like the Petzold book does (or like us old timers did back in the dark ages).
Just my thoughts, I'm sure there are others out there!
You could also do this with a cheap PIC chip to act as an I/O controller. Maybe Dr. A or Heater could consider using something like this to create an authentic looking IMSAI or ALTAIR MITS front panel for their CP/M machines. How cool would that be ??
Just thinkin' out loud.....
FF
If you want it cheap, switch-entry is certainly not cheap, or very friendly. Those 8 (min) toggle switches will cost MORE than your controller!
It was ONLY done this way, way back when, because there were no PCs in every home/office.
There are shiploads of good small uC simulators, here is just one example :
http://www.edsim51.com/
Even Real-Silicon, connected to a PC-Debug is remarkably cheap - even 32 bit ones can be found for under $20
This one is $4.35, even from Digikey ?! (can anyone do better ? )
http://www.ti.com/lit/wp/slay017/slay017.pdf
So you are probably much better off taking some very-low-cost PC-connected platform, like that LAUNCHPAD DEV BRD FOR MSP430G2XX, and expanding that with application/education examples.
sm
http://www.ti.com/lit/ds/symlink/tca8418.pdf
BTW, on my designs my 4-pin Prop plug connection is actually a 4x2 footprint with I2C and VCC lines plus one special funtion. A normal PropPlug can still plug in to the first row of 4 pins. This is also a way I can plug in special interfaces and also perform firmware upgrades in the field with a dedicated stamp sized module which puts the Prop into reset and loads it's EEPROM directly. The same footprint takes my tiny USB to serial module (1.1" x 0.45") which can even be soldered into place as a permanent microUSB interface.
I've used the MCP23017 in a few projects -- very easy to use if you're not worried about super-fast access (if it's monitoring mechanical switches that is not an issue). Bonus is that it's a bidirectional device.
wow. That is tiny.
Does anybody have any practical tips for handling these little BGA guys?
I was looking at some GaN power MOSFETS and ran into the same miniature BGA like solder connections that required very special step heat and flux removal. Our home brew techniques which more resemble stone axe and club than tight tolerance science need to keep pace with technology.
As for BGA I stay away from it because I can. I don't mind working with any other SMD stuff but unless you are setup for BGA and can guarantee alignment and controlled reflow I think it would be too much of a headache. Besides densely packed BGA really requires a multilayer PCB and they are much more expensive, especially when you are prototyping. The BGA package cannot be probed or patched either. Great for high-volume, too much trouble and expense for anything less IMO.
-Phil
The R2R method is very limited by resolution and tolerances and although it could work fine for maybe 4 switches it is a different story when it comes to 8 switches and 256 levels (or more) to resolve with precision. Yes, resistors are "simpler" than a chip but a chip is far easier to implement and will take a smaller footprint. If these were individual push-buttons rather than dip switches it would be possible to string them together with a single resistor of the same value per switch which would be fairly easy to resolve with sufficient precision.
This method has been used commercially for the last 20+ years, with more than 4 bits. The propeller, with a sigma delta ADC, will have no trouble resolving the values with a 9bit software ADC. It might even work reliably with an 8bit ADC, yielding precisely the same value as the dip switch.
Ford has used this technique since the 80's for multiplexing the cruise control buttons on the steering wheel.
The switches, presumably single NO contacts, won't work by themselves. R2R networks have the bit inputs driven both hi and low.
However, with the switch this is not the case. As I see it, you would need a CMOS buffer, or at least a low value pullup resistor.
Am I wrong?
Duane J
-Phil
At that point you may as well trade for a shift register, but it's still worthwhile discussing "old" techniques, for fear of people getting their brain boxed into certain ways of thinking.
The cruise control you mentioned though might be built using momentary action switches in which case it is easy to implement a resistor ladder (not R2R) as only one button will be operated at a time. I've used this technique in vending machines many years ago to cut down on the wiring loom for the selection buttons so that each switch is connected to it's neighbor with a resistor plus a common. This resistor string is at maximum value when no switches are pressed and decreases depending upon which tap is connected to ground.
Sometimes I think our digressions, even though we enjoy them, must certainly confuse the OP. Oh well, it's a forum. By all means pedward, don't stop with alternatives, we all love a skeet shoot