Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : CMM interfacing with 5V CMOS
Page 1 of 7 | |||||
Author | Message | ||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Hello, yet another question from the pits of ignorance. What's the simplest way (ideally using no additional silicon other than perhaps a transistor or two) to interface the CMM with a 5V CMOS IC (e.g. the shift register in an NES controller) ? - a direct connection isn't working presumably because the CMM digital output high is only 3.2V, or possibly I fried the shift register already ;-) Am I correct in thinking the solution involves configuring the outputs as open collector and use an external 5V power source (or the CMM's 5V rail) and a pull up resistor? I guess that will reverse the highs and lows? Regards, Tom Edited 2020-03-31 08:35 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
PeterB Guru Joined: 05/02/2015 Location: AustraliaPosts: 639 |
G'Day Tom A healthy 3.3V device will drive a healthy 5V device. The CMM will need the pullups activated. From memory CMOS voltages are 0.6 for a zero and 2.2 for a one or something. The output of a CMM should be zero and 3.3. If it doen't work you may have let Grogster's smoke out Can you look at the output voltages using a CRO/DSO/multimeter/wet finger/??? Good luck Peter |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1584 |
Hi Tom, Apparently the shift register in an NES controller is a CD4021. The minimum logic one input voltage (from the data sheet) is 3.5 volts when powered with 5 volts. So if it works at all it's likely to be iffy, a simple transistor invertor/level shifter should do it. An NPN transistor with a 100K base resistor with a 10K collector resistor to 5 volts (or >4 volts) should be OK. The exact values are not at critical. Bill Keep safe. Live long and prosper. |
||||
PeterB Guru Joined: 05/02/2015 Location: AustraliaPosts: 639 |
OOPS! Thanks Bill. I must be slipping. I used that stuff a lot in the past. I know, I'm getting old. Peter |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 3422 |
Dear thwill, If you want to drive a shift register, you most likely need to drive 3 or more lines (clock, data, enable). I suggest you interface between the CMM and the NES with a 5V TTL logic buffer. TTL logic has input levels that are 3.3V compatible, and outputs drive 5V (the CMOS versions). I suggest you use a 74HCT125 (quad non-inverting buffer with enable). It does the level shifting, and by means of the enable pin you can always disable it's output. And it is less soldering than 3x NPN transistor, 6x resistor....... Regards, Volhout PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8516 |
Use any of pins 11-20. Set them as open collector and use an external pullup resistor to 5V - easy Edited 2020-03-31 20:48 by matherp |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1584 |
Thanks matherp Bill Keep safe. Live long and prosper. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
G'Day Tom Hello Aussies and token dutchman ;-) Peter, I know that Bill called you out on your numbers, but despite that can you tell me what you mean by "The CMM will need the pullups activated" ? I've read in passing that the Arduino has configurable pullups (whatever that might mean), but not seen anything in MMBasic to suggest the same of the Maximite. Bill, this seems to be the similar to the open collector approach but using an external NPN ... is that correct? Volhout, thanks for recommending some silicon. If I was doing more than playing I would definitely be looking at that approach. But instead I have a heap of discrete Chinese transistors and an appreciation of the relaxing possibilities of soldering ;-) Matherp, thanks, I thought something like that must be possible. That does reverse the logic though like the external NPN approach above doesn't it? I haven't had a chance to try out any of these approaches yet, it turns out "lockdown" with small children is not conducive to getting time in the man cave. Additionally I have realised that the next thing I should try is supplying the controller with 3.3V instead of the 5V spec'd and see whether "it just works" with the Maximite logic-levels. Best wishes, Tom Edited 2020-04-01 09:36 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Hello Aussies and token dutchman ;-) Peter, I know that Bill called you out on your numbers, but despite that can you tell me what you mean by "The CMM will need the pullups activated" ? I've read in passing that the Arduino has configurable pullups (whatever that might mean), but not seen anything in MMBasic to suggest the same of the Maximite. Bill, this seems to be the similar to the open collector approach but using an external NPN ... is that correct? Volhout, thanks for recommending some silicon. If I was doing more than playing I would definitely be looking at that approach. But instead I have a heap of discrete Chinese transistors and an appreciation of the relaxing possibilities of soldering ;-) Matherp, thanks, I thought something like that must be possible. That does reverse the logic though like the external NPN approach above doesn't it? I haven't had a chance to try out any of these approaches yet, it turns out "lockdown" with small children is not conducive to getting time in the man cave. Additionally I have realised that the next thing I should try is supplying the controller with 3.3V instead of the 5V spec'd and see whether "it just works" with the Maximite logic-levels. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Damn, double post Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
PeterB Guru Joined: 05/02/2015 Location: AustraliaPosts: 639 |
Tom. I am reluctant to offer advice after my last effort but what-the-hell. The SETPIN command allows you to configure a pin as input or output AND! If set to OUTPUT, it can be driven high or low by a FET OR! it can be set to OC which means it is driven by an open drain FET connected to ground so the pin needs to be pulled high by an R. MatherP (the showoff) has noted this and points out that some pins can go to 5V. There is no inversion of the signal. It is all just so easy.......... If you are not senile. Peter |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1584 |
Tom, To answer your question to me, yes it is similar to using matherp's suggestion but using an external transistor WOULD cause an inversion. As PeterB's explanation sort of says - using SETPIN Pin, OOUT disables the internal pullup (sourcing) FET so that an external resistor must be used to pull the output high and because the pin is 5 volt tolerant that resistor can be connected to 5 volts or whatever voltage you get after the Maximite's internal diode. You will only need resistors on the clock and P/S Cont. outputs, the Data in is a digital input and does not need a resistor. All pins must be 5 volt tolerant. Because "It is all just so easy..." I would get it working before trying the controller on 3.3 volts. I have found that with similar circuits that there is no need for delays in clocking in and reading the data, the interpreter is slow enough not to need them: set the clock output read the data in shift it along reset the clock output loop until done Bill Keep safe. Live long and prosper. |
||||
PeterB Guru Joined: 05/02/2015 Location: AustraliaPosts: 639 |
G'Day Bill & Tom "As PeterB's explanation sort of says" Sort of!!! There is no pleasing some people. It is perfectly clear to me. However, If I go back and read it in 12 months time (if I'm still here) I will wonder who wrote this rubbish. Such is the nature of technical writing. But you do at least agree with it. Peter Edited 2020-04-01 16:42 by PeterB |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1584 |
Sorry Peter, I just thought that the bit about "can be driven high or low by a FET" was a bit confusing and might suggest an external FET. But I could be senile Bill Keep safe. Live long and prosper. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Hello again, I've not tried configuring the pins as open collector yet (an activity for tomorrow), but tying NES/Famicon controller to the Maximite's 3.3V rail worked ... I now realise one of the problems I was having previously is that I was expecting the buttons to drive DATA high ... they drive it low - D'Oh! In case another novice stumbles across this thread, here is some code: LATCH = 1 CLOCK = 2 DATA = 3 DURATION = 0.012 ' 12 micro-seconds SetPin LATCH, dout SetPin CLOCK, dout SetPin DATA, din Pin(LATCH) = 0 Pin(CLOCK) = 0 Do Pulse LATCH, DURATION out = &h0 For i = 0 To 7 If Not Pin(DATA) Then out = out Or 2^i Pulse CLOCK, DURATION Next i If out And &h01 Then Print "A "; If out And &h02 Then Print "B "; If out And &h04 Then Print "Select "; If out And &h08 Then Print "Start "; If out And &h10 Then Print "Up "; If out And &h20 Then Print "Down "; If out And &h40 Then Print "Left "; If out And &h80 Then Print "Right "; Loop Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
OK, so though it worked (off-spec?) at 3.3V I can't get it to work at 5V The schematic (I think) I've constructed is: With the connections to the Famicon/NES controller (CD4021 shift-register) on the left and the connections to the Maximite's 26-pin GPIO on the right. My program is: LATCH = 11 CLOCK = 12 DATA = 13 DURATION = 0.012 ' 12 micro-seconds SetPin LATCH, oout SetPin CLOCK, oout SetPin DATA, din Pin(LATCH) = 0 Pin(CLOCK) = 0 Do Pulse LATCH, DURATION out = &h0 For i = 0 To 7 If Not Pin(DATA) Then out = out Or 2^i Pulse CLOCK, DURATION Next i If out And &h01 Then Print "A "; If out And &h02 Then Print "B "; If out And &h04 Then Print "Select "; If out And &h08 Then Print "Start "; If out And &h10 Then Print "Up "; If out And &h20 Then Print "Down "; If out And &h40 Then Print "Left "; If out And &h80 Then Print "Right "; Loop The "A" button (first-bit of data in the shift register) is being read correctly but other single button presses are not, some combination presses are coming through (partially), e.g. "A" + "B" -> "A" + "B" "Start" + "Select" -> "Select" "A" + "B" + "Select" + "Start" -> "A" + "B" + "Select" + "Start" As far as I can tell with my "toy" DSO138 and limited skills the latch and clock are all pulsing correctly, but I'm not getting the correct pulses back on the data line. Any ideas? Best Regards, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Three other pieces of information: 1) If I tie the controller VCC and the CLOCK & LATCH open collectors to 3.3V it shows the same symptoms as with them tied to 5V. 2) If I tie the controller VCC to 3.3V and make LATCH and CLOCK din it works fine, i.e. those pins aren't bust, at least under normal (non open-collector) operation. 3) If I detach the DATA line from the CMM and just connect it to the DSO the output is consistent with when the DATA line is attached to the CMM, i.e. I think the CMM is reading the DATA line correctly. I am at a loss, even if the controller is not 5V compatible I would have expected (1) to work. Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Bill.b Senior Member Joined: 25/06/2011 Location: AustraliaPosts: 225 |
Hi all I have found these devices useful when interfacing to 5v ws2812 LED strip lights Here Bill Edited 2020-04-05 08:29 by Bill.b In the interests of the environment, this post has been constructed entirely from recycled electrons. |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1584 |
OK, presuming that in item 2 you mean DOUT not DIN and you don't have your LED matrix connected as well, the difference between it working and not working COULD be the impedance when the output signals are driven high. The clock and latch pulses may not be getting through properly due to long leads and capacitance. It seems that the "A" button is always correct because it does not rely on a clock pulse to be read. I would try lengthening the clock and latch pulses and/or lowering the pullup resistor values to (say) 1K. I would prefer to not have a clock pulse at all and do something like: For i = 0 To 7 Pin(CLOCK) = 0 If Not Pin(DATA) Then out = out Or 2^i Pin(CLOCK) = 1 Next i Pin(CLOCK) = 0 Good luck. Bill Keep safe. Live long and prosper. |
||||
flip Senior Member Joined: 18/07/2016 Location: AustraliaPosts: 114 |
Hi Tom, Assuming the directions as per your program are correct, it may be good to drop the 0-5V swing from the device to 0-3.3V required by the mite. Can do this by a) inserting 1.8k in-line between Device's Data Pin and Pin 3 on uM, and b) inserting 3.3k between Pin 3 on uM and GND Ratios are important, values may want to adjust...probably 18k and 33k will work just as well. Assuming devices not blown, and assuming the signal directions as you've noted. Regards Phil Edited 2020-04-05 09:36 by flip |
||||
Page 1 of 7 |
Print this page |