Main Site Documentation

Can not use SPI - OutputPort too slow - is Register class direct access an option?


#1

I have a chip that does not work with SPI so I have to “bit bang” it.

The OutputPort is so slow I can see the lights update like a chaser pattern instead of the instant update I am looking for. I had the same speed issues in the netduino. In arduino I had to use direct memory access to get the speed needed. I am thinking I may need to do the same here but wanted to see if there are any other alternatives for faster pin updates.

  • Seem from reading I would setup using OutputPort to the pin for proper setup … but then I could use the Register class to set the pin value quicker than using Write. If this is the only alternative and is correct … I need help with the address for pins d8 and d9.

  • I realize I am a newbie attempting to use advanced features right off the bat … but I have a very focused goal. Once I see the system can handle running the number of chips needed, then I’ll work on all the fun stuff around it.


#2

There is a lot involved in toggling pin on NETMF so bit banging work is not recommended.

What is the chip you are using that needs bit banging?


#3

The LPD6803 (among others) inside the LED that come with IC’s built in. I have tried everything in arduino to work it using SPI, no luck (yet).

The datasheet is in Chinese only and can no longer find a link online. The example code in the datasheet is bit bang (data on/off - clock on/off).

I was hoping with the Register class I would be able to do this from managed code. In netduino someone wrote a “bit banger” native code driver, but it takes a firmware build / update. Sounds like learning the firmware build / update process may be easer than bit banging FEZ.

All this is experimental anyway … I may have to just go arduino mega and/or distributed.

I can run this chip or any other working with SPI … I’ll come back and try again with this environment as it seems very mature. I may still be able to use FEZ to multiple arduino controllers since memory is my big problem when running hundreds of LEDs.

Thank you for your quick reply.


#4

if you need a translation of the datasheet i can offer you my help. I can’t do the full translation though because of time. But I would be happy to translate the parts that you need.


#5

Do you have a link to datasheet?


#6

@ terrorgen - that is a very nice offer. I am able to understand the datasheet enough due to the numbers being in english and the code being readable due to using english constants. Also have working code to start from in arduino from bliptronics.com and have an english version of another chips datasheet that is 100% compatible (D705).


#7

You can use OutputCompare on FEZ to do bit banging.


#8

Finally found the D705 datasheet - same animal.

http://www.leds.ru/pdf/D705_en.pdf


#9

I think I understand OutputCompare but not how to use it to simulate a clock / data pair.

Just using Set with true/false is not helping any. It seems I need to use the overloaded call that includes a stream and count of how many pulses to send.

I created a two entry (on/off) entry to toggle the clock which seemed to help, but very little.

I’ll keep working to see if I can use this to do clock and data both. Obviously they just need to be in sync and I am not sure how to achieve this exact timing.

I may need a more raw “bit bang” capability to keep down the complexity. Bit banging 50 to 200 chips can’t be too much for this powerhouse (and the netduino) when the little arduino runs it faster than the eye can see. There has to be a way … I’ll keep plugging away at it.

Thanks for the pointers.


#10

I do nothink you can…you can’t read and you can’t sync 2 waveform easily.


#11

I looked at the datasheet and that is all SPI 100% not single doubt :slight_smile:

Now one thing I noticed is that the input high level is VDD * 0.7, that is 5*0.7=3.5V

So you need more than 3.5V to make the signal go high but FEZ is 3.3V so you will never see 3.5V and so this will never work on SPI… which explain why it didn’t work for you :slight_smile: The problem is not SPI but it is the voltage levels

What you need is to use some logic chip that is powered off 5V but has 2V (TTL) high level input, this way, the chip will see 3.3V levels just fine and provide 5V output to the LED driver. Another option is to use transistors.


#12

I can work with the chip just fine making it go high and low with direct pin action, is there a difference in the voltage when using SPI?

The chips are working fine and doing what they are suppose to … just really slow.

if I make any breakthroughs (even if it is getting the bit banger native working in netduino) … I’ll let you know what the solution and speed differences are.

Thanks again for all the responses.


#13

I want to thank you for providing Panda at cost to try it out. It was worth the $20 to play with a real live Panda. The quality and features on the FEZ Panda is mind blowing for the price. Your support on the forum is immediate and helpful.

Too bad it does not look like Panda will fulfill my needs. My show stopper issue is that Panda has slow pin speed (per above thread) and there is apparently no easy solution (no direct port access like arduino). Same issue with netduino too, but they have a bit-banger native driver that requires a rebuild and reloading of the firmware. If you can find a way to provide a mechanism for fast “bit bang” speed - then your product may have a slightly wider audience, maybe not worth your time though.

I’ll post details if I make this a master controller running arduinos that are do the low level work or come up with a work around the speed issues.

Thanks for all your replies in attempts to help me get around this issue. I am sure I’ll have a fun project or two that Panda can handle and will post projects details in the appropriate places.

Regards and happy FEZ’ing.


#14

If the chip your trying to talk to is SPI than there is no issue with speed and no issue with needing to bit bang anything. Just use a level shifter to get the voltage level up to what your chip expects and your done.


#15

I have yet to see this chip working with SPI - even in arduino (5v).

As for voltage … this is the second person that mentioned that, but …

  • I can control the chip with the 3.3v, no problem.
  • I can not control the chip via SPI -even with 5v from the arduino.
    … so what factor am I leaving out that would make a voltage difference help?

I would love to get the chip working with SPI … if so, a mega would easily handle the load. The datasheet for the LPD6803 makes it seem like a no brainer for SPI … but no luck in implementing in any environment yet.

So my statement is … if you can not use SPI … then these framework based tools are apparently not going to fit the bill unless someone can come up with a bit banger like someone posted in the netduino forum. That bit banger requires a firmware rebuild to use, which is my next goal - learning to build and flash the firmware on the netduino. Why I was hoping the Register class would fit the bill - no firmware builds needed.


#16

[quote]As for voltage … this is the second person that mentioned that, but …

  • I can control the chip with the 3.3v, no problem.
  • I can not control the chip via SPI -even with 5v from the arduino.
    … so what factor am I leaving out that would make a voltage difference help? [/quote]

You are still not following the specifications so all these arguments are not valid.

That is incorrect. An SPI bus is a bit-banger done in hardware. Why would a bit banger make this work but SPI doesn’t? I have looked at the datasheet and I have not a single doubt that this will work on SPI.

Either way, have fun and let us know if you have made any progress.

One last question: Does it work when you bit bang but it is too slow? Did you try to run SPI at a slow clock rate? Did you check the clock settings? There are 4 possible SPI modes. Do you have a scope so you can verify what you are doing?


#17

Yes

I tried in arduino using the slowest speed … I should try SPI here as well.

No - I am one of those software guys coming over into hardware land (well over a hear ago). I don’t have all the cool tools or hardware knowledge. Just trying to use the tools provided to make cool stuff happen :slight_smile:

Thanks again for attempting to help, I’ll let you know if I am able to get the speed I need using the netduno bit banger or get SPI working with any of these odd chips.