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.
Joined: 24/04/2017 Location: United KingdomPosts: 2
Posted: 10:34pm 25 Apr 2017
Copy link to clipboard
Print this post
Hi I'm a new be to this sight I'm building a jukebox around a jukebox carousel and buttons I want to input 30+ buttons into a micromite controller I have chosen a micromite for the autorun so it will start from switch on . I'm thinking of using a 74hc165 shift register daisy chain 4 of them together for the 32+ old latch type buttons from a jukebox. I did a course On vbasic about 10 years ago so I'm hoping it might help me. I'm after the coding for the 74hc165 in mmbasic there's plenty of of coding on the arduino but not for the micromite. I want to input from the buttons and store them and use the selection to run the carousel. So I'm hoping that someone will have used the 74hc165 on a micromite in mmbasic or point me in the right direction. Yours Phill
SteveA Regular Member
Joined: 10/03/2017 Location: United KingdomPosts: 48
Posted: 04:47am 27 Apr 2017
Copy link to clipboard
Print this post
Have you considered I2C port expander IC's instead?
For example, the MCP23017 gives you 16 I/O pins. You can have up to 8 on an I2C bus, giving you 128 pins to play with. And I2C is baked into the MM, so driving them is easy!
Rgds,
Steve
matherp Guru
Joined: 11/12/2012 Location: United KingdomPosts: 8592
Posted: 05:10am 27 Apr 2017
Copy link to clipboard
Print this post
The coding on the Micromite should be trivial. Tie all the clocks together and all the LD pins together. Tie all CLKINH pins to GND. Connect serialout to serial in across three of the chips and serialout of the 4th chip to a pin(data) on the MM
toggle LD low to load in the data. then clock out the data a bit at a time into an array
something like:
dim b%(32) setpin LD,dout setpin clock,dout setpin data,din pin(LD)=1 pin(clock)=0 do readbits() loop
sub readbits local i% pulseout LD,0.01 for i%=0 to 31 pin(clock)=1 b%(i%)=pin(data) pin(clock)=0 next i%
CaptainBoing
Guru
Joined: 07/09/2016 Location: United KingdomPosts: 1985
Posted: 05:28am 27 Apr 2017
Copy link to clipboard
Print this post
won't be too hard to do. Your VB will come in handy - the MMBasic primitives (i.e. the built in commands, functions and statements) have a very familiar feel to VB programmers
for your shift registers; Take all the CE pins to GND, Link all the PL pins together to an Output pin on the MM - hold this pin Hi normally Link all the CP pins together to an output pin on the MM - hold this pin Hi normally Take the Q7 pin of 3 of the 165s to the corresponding DS on the next to "cascade the data" take the
On PL, send LO then Hi to grab your switch data
On CP, send lo then hi and sample Q7 of the highest 165. Repeat this as many times as you have switches to determine which button is pressed. Stop when you find a button pressed (unless you want to detect multiple presses)
Code might look like this:
CONST PL=1, CP=2, Q7=3 ' change these to whatever pin numbers you use
DIM Switches AS INTEGER ' variable to hold the switch status as a bit array DIM n AS INTEGER ' counter for your loop
SETPIN PL,DOUT SETPIN CP,DOUT SETPIN Q7,DIN
PIN (PL)=1 PIN (CP)=1
' this is the point you capture the switch data Switches=0 ' clear any old data PULSE PL,1 ' 1mS pulse to grab switches
FOR n=31 TO 0 STEP -1 ' change 31 to 29 if you only want 30 switches Switches=(Switches<<1) + PIN(Q7) ' gradually build switch status in variable PULSE CP,1' shift next bit NEXT
' here Switches has a bit array of the switches that were pressed
probably more to it than this simple "thinks" but should be enough to get you going.
hth
CaptainBoing
Guru
Joined: 07/09/2016 Location: United KingdomPosts: 1985
Posted: 05:32am 27 Apr 2017
Copy link to clipboard
Print this post
sorry Peter, not competing I evidently took 18 minutes to type that in
Phill sug Newbie
Joined: 24/04/2017 Location: United KingdomPosts: 2
Posted: 08:47pm 29 Apr 2017
Copy link to clipboard
Print this post
Thanks for the response just going on holiday so wil have a look when I get back Thank Phill