Any help on a ParallelIn SerialOut Bitshifter?
#1
Posted 30 March 2011 - 09:15 PM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#2
Posted 31 March 2011 - 07:14 AM
- Stefan and like this
#3
Posted 31 March 2011 - 07:37 AM
I starting to really really like you
I didn't posted that on purpose because sometimes it just helps to unplug everything and start over again with a clean mind (in my experience).
The numbers I got were all but consistent to what I pushed. I tried push buttons with and without pull resistor (according to this schematic) and some other stuff, but nothing helped much.
I see you do "- /CE (15) to ground".
I can't recall I had two black cables to my IC, going to try that out tonight.
LOL! I did the same, just ordered a couple of HC IC's (yep, the real CMos versions) just to toy with. they're cheap and fun (if it works!)I'll going to buy a couple of 165 also on the next weekend, but you may try to check these points in the mean time.
Thanks (again) for the help so far! Tu sei buono!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#4
Posted 31 March 2011 - 10:01 AM
You must add the pullup resistor by using any external IC. The "internal pullup" feature is particular of certain MCUs, not ordinary logic.I tried push buttons with and without pull resistor
Take care about avoid confusion.
The term "pullup" means resistor connected to the positive voltage (e.g. +5V), while pulldown is toward ground. If you choose to connect your buttons from +5V and the IC's input, you must use pulldowns.
However, it is most common habit to keep the reference to the ground. So connect pullups and buttons shorting to the ground. The logic is inverted, but it has electrical advantages.
Thanks for that, but I am just applying what you have sad: "It's never too late to learn". As far I may teach something to anyone, I'll learn something else. (That is the case of C native programming)Thanks (again) for the help so far! Tu sei buono!
Cheers
#5
Posted 31 March 2011 - 10:35 AM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#6
Posted 31 March 2011 - 11:43 AM
#7
Posted 31 March 2011 - 11:46 AM
Indeed, with only 2 pins, it would be hard to press them without pushing them aside.Your buttons should be the same model I have too. Their four pins are mainly useful for mechanical reasons.
Haha sounds slightly familiar I must confess.I cannot count how many times, looking for a problem, I was convinced to search in the most complex section. The real meaning is that I hadn't switched the power on.
Going to retry tonight!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#8
Posted 31 March 2011 - 05:59 PM
(click for the bigger picture)
this is the code:
SPI spi = new SPI(new SPI.Configuration( Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 1000, SPI_Devices.SPI1 )); OutputPort latch = new OutputPort(Pins.GPIO_PIN_D10, true); byte[] wb = new byte[1]; byte[] rb = new byte[1]; uint i = 0; while (true) { ++i; latch.Write(!latch.Read()); spi.WriteRead(wb, rb); latch.Write(!latch.Read()); Debug.Print(i.ToString() + ":" + rb[0].ToString()); Thread.Sleep(500); }And this is the output:
I pressed all buttons, nothing changed, until I pressed button 8. Then it went to 0. I pressed ONLY button 8, so I would expect 254 or 127, depending on the bit sequence.1:255
2:255
3:255
4:255
5:255
6:255
7:255
8:0
9:0
10:0
11:255
12:255
13:255
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#9
Posted 31 March 2011 - 06:26 PM
#10
Posted 31 March 2011 - 06:29 PM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#11
Posted 31 March 2011 - 06:36 PM
The /PL line should pulsed low *before* the beginning of the SPI transfer.
The /PL line, when low, copies the inputs status to the shift register: as long the /PL is low the buttons are copied to the shifter. That's because by pressing the 8' button, you read all zeroes!...The SPI clocks correctly, but the latest latch is always refreshed by the /PL!
Correct the loop as follows:
while (true) { ++i; latch.Write(false); latch.Write(true); spi.WriteRead(wb, rb); Debug.Print(i.ToString() + ":" + rb[0].ToString()); Thread.Sleep(500); }Cheers
- Stefan and like this
#12
Posted 31 March 2011 - 06:44 PM
SPI spi = new SPI(new SPI.Configuration( Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 1000, SPI_Devices.SPI1 )); OutputPort latch = new OutputPort(Pins.GPIO_PIN_D10, true); byte[] wb = new byte[1]; byte[] rb = new byte[1]; uint i = 0; while (true) { ++i; latch.Write(!latch.Read()); latch.Write(!latch.Read()); spi.WriteRead(wb, rb); Debug.Print(i.ToString() + ":" + rb[0].ToString()); Thread.Sleep(500); }
I placed my multimeter in this setting:
When I push the button the meter shows (almost) zero. the same counts for all buttons.
Ps, I'm in the chat, if you like
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#13
Posted 31 March 2011 - 06:49 PM
#14
Posted 31 March 2011 - 07:58 PM
Schematic:
Code:
SPI spi = new SPI(new SPI.Configuration( Pins.GPIO_NONE, true, 0, 0, false, false, 1000, SPI_Devices.SPI1 )); OutputPort latch = new OutputPort(Pins.GPIO_PIN_D10, true); byte[] wb = new byte[1]; byte[] rb = new byte[1]; uint i = 0; string binpresentation = ""; while (true) { ++i; latch.Write(false); latch.Write(true); spi.WriteRead(wb, rb); binpresentation = ""; for (var PinCount = 0; PinCount < 8; ++PinCount) { binpresentation = binpresentation + (((rb[0] & (1 << PinCount)) != 0) ? "1" : "0"); } Debug.Print(i.ToString() + ":" + binpresentation); Thread.Sleep(500); }
Problem:
Buttons 1 and 2 are sometimes malfunctioning (not due to wiring, and multimeter readings are fine);
When nothing pressed it gives 01111111 or 11111111
When button 1 pressed, same result
when button 2 pressed: 00111111
when button 3 pressed: 11011111
when button 4 pressed: 11101111
when button 5 pressed: 11110111
when button 6 pressed: 11111011
when button 7 pressed: 11111101
when button 8 pressed: 11111110
Almost there!
Now I'm going to try something with the 597, while Mario is asleep
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#15
Posted 31 March 2011 - 08:26 PM
SPI spi = new SPI(new SPI.Configuration( Pins.GPIO_PIN_D10, true, 0, 0, true, false, 1000, SPI_Devices.SPI1 )); byte[] wb = new byte[1]; byte[] rb = new byte[1]; uint i = 0; string binpresentation = ""; while (true) { ++i; spi.WriteRead(wb, rb); binpresentation = ""; for (var PinCount = 0; PinCount < 8; ++PinCount) { binpresentation = binpresentation + (((rb[0] & (1 << PinCount)) != 0) ? "1" : "0"); } Debug.Print(i.ToString() + ":" + binpresentation); Thread.Sleep(500); }
This seems to work! Now the code just needs some clean up, and I need a second IC to put them in serie
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#17
Posted 01 April 2011 - 03:40 AM
#18
Posted 01 April 2011 - 06:20 AM
Hi Mario,The only point is the missing /PL on your source: it cannot be missing.
Cheers
I noticed that it works perfectly when I chose to let the SPI take care of /PL:
SPI spi = new SPI(new SPI.Configuration( Pins.GPIO_PIN_D10, // PL true, 0, 0, true, false, 1000, SPI_Devices.SPI1 ));The 165 doesn't have a buffer as far as I read and this way all of my tests worked.
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#19
Posted 01 April 2011 - 06:51 AM
#20
Posted 01 April 2011 - 07:17 AM
People use Pins.None when they want to run multiple SPI devices and control the SS-pin themselves by code, or in my case, to be 100% sure of the behaviour during testingI apologize: I didn't notice the Pins.D10 on the SPI config.
To tell the truth, I still had not understand why sometime the SPI is configured using Pins.None.
I myself have a MultiSPI-class which will be available soon, which does the trick quite nice as well.
Cool! I also have two 597s to test, it's a difficult one but I want to understand that one as wellTomorrow I'll try to find time to buy the '165, but I am totally involved in the setup of the porting kit, at the moment.
I'm also going to order a second 165, to put two in a serie, which should be possible.
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users