Any help on a ParallelIn SerialOut Bitshifter?
#21
Posted 06 April 2011 - 08:23 PM
Software needs some improvements, comments and such, but that won't take too long. Yay!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#22
Posted 07 April 2011 - 03:32 AM
#23
Posted 07 April 2011 - 06:07 AM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#24
Posted 07 April 2011 - 07:03 AM
#25
Posted 07 April 2011 - 07:45 AM
Indeed. I also found that out while working with SPI.I begin having fewer time for this kind of games, because I am involved as organizer in the next spring country fest.
Anyway, with the little time I may find, I'd like to try to write my own native library, because I think there are many serious gaps in the current framework.
Strange SPI things I found:
- SPI is made for multiple devices on one serial bus, but the NETMF doesn't have a decent way to handle this. Wait until my MultiSPI wrapper-class is done! I improved this very nicely
- SPI read-only isn't possible. For example, I connected the 74HC165s with three cables: SS, MISO, SCLK. Should be enough, appairently it's enough since it works. But there isn't a SPI.Read() function, I still have to write the exact same number of bytes I want to read with SPI.WriteRead(). I tried to write 0 bytes and read 2 but that won't work. Writing 1 byte and wanting to read 2 makes everything hang. But there is no way it could write a thing since there is no MOSI connected! Therefore I'm considering to make a Read()-method in my wrapper-class that writes empty bytes and reads everything.
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#26
Posted 07 April 2011 - 08:05 AM
Have you tried passing 'null' write buffer?I tried to write 0 bytes and read 2 but that won't work. Writing 1 byte and wanting to read 2 makes everything hang.
#27
Posted 07 April 2011 - 08:17 AM
not yet, good one, going to try that tonight! Still, my point that a Read() only function is lacking is a fact If null works, I'm going to use that in my wrapper.Have you tried passing 'null' write buffer?
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#28
Posted 07 April 2011 - 09:01 AM
I think it's a good idea, but *ANYWAY* never never the systems should hang because any data has been passed wrong. Maybe failing the operation, but hanging must be avoided as the hell.Have you tried passing 'null' write buffer?
Stefan, consider also that I am still scared about the occupation of the TinyCLR itself, which is missing of many libs. So, by adding redundant calls or whatever else, is going only worser.
Ciao
#29
Posted 07 April 2011 - 09:06 AM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#30
Posted 07 April 2011 - 11:49 AM
SPI.Configuration cnf = new SPI.Configuration(Pins.GPIO_PIN_D10, false, 0, 0, false, false, 1000, SPI_Devices.SPI1); SPI spi = new SPI(cnf); byte[] wb = new byte[3]; byte[] rb = new byte[3]; spi.WriteRead(wb, rb); spi.WriteRead(null, rb);it breaks on the last line with:
An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#31
Posted 07 April 2011 - 12:08 PM
#32
Posted 07 April 2011 - 12:14 PM
public void Read(byte[] ReadBuffer) { byte[] WriteBuffer = new byte[ReadBuffer.Length]; _spi.WriteRead(WriteBuffer, ReadBuffer); }
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#34
Posted 07 April 2011 - 12:21 PM
Darn, you're clever mate!
public void Read(byte[] buffer) { _spi.WriteRead(buffer, buffer); }
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#35
Posted 11 April 2011 - 06:44 AM
using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; using StefanCo.NETMF.Hardware; namespace NetduinoApplication1 { public class Program { // In the global scope so the leds will be available at all time private static OutputPortShift[] Leds = new OutputPortShift[16]; public static void Main() { // We have two 74HC165 IC's in a chain Ic74HC165Chain ChainIn = new Ic74HC165Chain(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, 2); Ic74HC165 IcIn1 = new Ic74HC165(ChainIn, 0); Ic74HC165 IcIn2 = new Ic74HC165(ChainIn, 1); // We have two 74HC595 IC's in a chain Ic74HC595Chain ChainOut = new Ic74HC595Chain(SPI_Devices.SPI1, Pins.GPIO_PIN_D9, 2); Ic74HC595 IcOut1 = new Ic74HC595(ChainOut, 0); Ic74HC595 IcOut2 = new Ic74HC595(ChainOut, 1); // All together, we got 16 Interrupt Ports InterruptPortShift[] Buttons = new InterruptPortShift[16]; Buttons[0] = new InterruptPortShift(IcIn1, Ic74HC165.Pins.GPI_PIN_D0, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[1] = new InterruptPortShift(IcIn1, Ic74HC165.Pins.GPI_PIN_D1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[2] = new InterruptPortShift(IcIn1, Ic74HC165.Pins.GPI_PIN_D2, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[3] = new InterruptPortShift(IcIn1, Ic74HC165.Pins.GPI_PIN_D3, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[4] = new InterruptPortShift(IcIn1, Ic74HC165.Pins.GPI_PIN_D4, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[5] = new InterruptPortShift(IcIn1, Ic74HC165.Pins.GPI_PIN_D5, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[6] = new InterruptPortShift(IcIn1, Ic74HC165.Pins.GPI_PIN_D6, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[7] = new InterruptPortShift(IcIn1, Ic74HC165.Pins.GPI_PIN_D7, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[8] = new InterruptPortShift(IcIn2, Ic74HC165.Pins.GPI_PIN_D0, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[9] = new InterruptPortShift(IcIn2, Ic74HC165.Pins.GPI_PIN_D1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[10] = new InterruptPortShift(IcIn2, Ic74HC165.Pins.GPI_PIN_D2, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[11] = new InterruptPortShift(IcIn2, Ic74HC165.Pins.GPI_PIN_D3, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[12] = new InterruptPortShift(IcIn2, Ic74HC165.Pins.GPI_PIN_D4, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[13] = new InterruptPortShift(IcIn2, Ic74HC165.Pins.GPI_PIN_D5, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[14] = new InterruptPortShift(IcIn2, Ic74HC165.Pins.GPI_PIN_D6, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Buttons[15] = new InterruptPortShift(IcIn2, Ic74HC165.Pins.GPI_PIN_D7, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); // And 16 Output Ports Leds[0] = new OutputPortShift(IcOut1, Ic74HC595.Pins.GPO_PIN_D0, false); Leds[1] = new OutputPortShift(IcOut1, Ic74HC595.Pins.GPO_PIN_D1, false); Leds[2] = new OutputPortShift(IcOut1, Ic74HC595.Pins.GPO_PIN_D2, false); Leds[3] = new OutputPortShift(IcOut1, Ic74HC595.Pins.GPO_PIN_D3, false); Leds[4] = new OutputPortShift(IcOut1, Ic74HC595.Pins.GPO_PIN_D4, false); Leds[5] = new OutputPortShift(IcOut1, Ic74HC595.Pins.GPO_PIN_D5, false); Leds[6] = new OutputPortShift(IcOut1, Ic74HC595.Pins.GPO_PIN_D6, false); Leds[7] = new OutputPortShift(IcOut1, Ic74HC595.Pins.GPO_PIN_D7, false); Leds[8] = new OutputPortShift(IcOut2, Ic74HC595.Pins.GPO_PIN_D0, false); Leds[9] = new OutputPortShift(IcOut2, Ic74HC595.Pins.GPO_PIN_D1, false); Leds[10] = new OutputPortShift(IcOut2, Ic74HC595.Pins.GPO_PIN_D2, false); Leds[11] = new OutputPortShift(IcOut2, Ic74HC595.Pins.GPO_PIN_D3, false); Leds[12] = new OutputPortShift(IcOut2, Ic74HC595.Pins.GPO_PIN_D4, false); Leds[13] = new OutputPortShift(IcOut2, Ic74HC595.Pins.GPO_PIN_D5, false); Leds[14] = new OutputPortShift(IcOut2, Ic74HC595.Pins.GPO_PIN_D6, false); Leds[15] = new OutputPortShift(IcOut2, Ic74HC595.Pins.GPO_PIN_D7, false); // We need to place an event on each button for (var i = 0; i < Buttons.Length; ++i) { // Points to the correct event handler if (i < 8) Buttons[i].OnInterrupt += new NativeEventHandler(IcIn1_OnInterrupt); else Buttons[i].OnInterrupt += new NativeEventHandler(IcIn2_OnInterrupt); // Enables interrupts Buttons[i].EnableInterrupt(); } // Now let's get the rest done by events Thread.Sleep(Timeout.Infinite); } static void IcIn1_OnInterrupt(uint PinId, uint Value, DateTime Time) { Leds[PinId].Write(Value == 0 ? true : false); } static void IcIn2_OnInterrupt(uint PinId, uint Value, DateTime Time) { Leds[8 + PinId].Write(Value == 0 ? true : false); } } }
This is the hardware setup (click on it for a bigger picture):
(with this schematic only one LED should be active at the same time, but only one resistor spared me some matarials and space on the breadboard )
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#36
Posted 11 April 2011 - 07:08 AM
#37
Posted 11 April 2011 - 07:19 AM
yep, but that seperate thread only starts when an interrupt is actually enabled and all interrupt ports use the same thread which actually exists in the class Ic74HC165Chain.Stefan, does the '165 wrapper run on a proprietary thread to poll the inputs?
I know it can become a performance issue, but the alternative is a more complex schematic. So I guessed as soon as performance gets an issue the developer just must get more creative
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#38
Posted 30 April 2011 - 04:02 PM
#39
Posted 30 April 2011 - 07:29 PM
That's something I have still to work on, haven't done it yet but it's quite possible!How can we integrate it with microliquidcrystal lcd class ? It is a question of integrating a new transport but I don't know how to do that lol
I can't read a single bit from a bitshift IC. To get the current state of a pin, I have to read them all.And did I see correctly, you re-read all pins for each pin status read ? wonder why !
Remember I gave you that link in chat once?Check this link :
http://geekswithblog...id_crystal.aspx
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#40
Posted 30 April 2011 - 09:07 PM
LoL me and my short term memory ...Remember I gave you that link in chat once?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users