Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Building custom go!bus modules for Netduino Go


  • Please log in to reply
102 replies to this topic

#41 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 19 April 2012 - 09:22 AM


We're selecting the parts right now. Are there any specs you'd prefer to see?


I think a Combined Temp/Humidity sensor would be a great idea instead of straight Temp. I am using the Sensiron SHT15 and found it works well and makes it easy to calculate Dew Point also.

I've also chosen the Honeywell HMC5883L 3 Axis Compass and The Analog Devices ADXL335 3-Axis Accelerometer. Currently I'm not using a Gyro.

Mostly these were chosen because there were breakout boards ready to go. However if I started from scratch, I think ST’s L3G4200D 3-axis gyroscope and LSM303DLH 3-axis accelerometer and 3-axis magnetometer might be a good choice as an all in one Module.

So, as far as specs...

1) Combined Temp/Hum with +/- 2deg accuracy.
2) 3 Axis on the Gyro, Accelerometer and Magnetometer
3) Most of all, low power consumption.

One more module idea I'll throw out there... a 5 way Navigation switch. For space savings I opted out of using 5 separate buttons for a single 5 way SMD switch.

#42 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 19 April 2012 - 10:12 AM

Great feedback, thank you.

One more module idea I'll throw out there... a 5 way Navigation switch. For space savings I opted out of using 5 separate buttons for a single 5 way SMD switch.

Ooh, I like :)

Chris

#43 ByteMaster

ByteMaster

    Advanced Member

  • Members
  • PipPipPip
  • 76 posts

Posted 22 April 2012 - 01:58 PM

It felt like Christmas last Friday. I received my GO! along with the Nwazet display and shield base modules. I also received a ton of cool stuff from Mouser to include a variety of STM8x discovery boards, a few STM8 chips and some sockets. My goal for the weekend was to try to arrange all this stuff to build a custom module. My intent is to mount an accelerometer, gyro and compass, write some custom software on the STM8 to do the communications with the sensors as well as processing, then finally make that output available to the Netduino GO! over the go!bus. Of course once I finish with my endeavor, I’ll publish the schematic/board and firmware as open source/hardware.

Setting up the STM tool chain was interesting, but not too bad. There are some good docs on the app notes on the pages for the different discovery modules.

My first goal was to just get a standard Netduino (hmmm…is “standard Netduino” the right term- Chris?) talking via SPI to the STM8 with the STM8 configured as an SPI Slave. It started out pretty promising in that the break-points where firing where I expected in ST Visual Develop (the IDE used to write C for the STM8). Here’s my setup.

Posted Image

Now for my question/problem. I spent most of Saturday afternoon trying to get the Netduino and STM8 to have a meaningful conversation. It seems like the conversation starts out fine where the first few bytes successfully get sent over. But after that when I read from the STM8’s SP RX register (after checking the receive buffer empty flag) it seemed to the values got out of step. I’m fairly sure it’s some sort of timing issue...hmmm, thinking about it, was it because I was debugging and screwing up my clocks?!?!?!

I’ve configured the Master SPI w/ NETMF as follows (with I thought was a very slow baud rate):
            var device1 = new SPI.Configuration(Pins.GPIO_PIN_D10, false, 0, 0, false,true, 200, SPI.SPI_module.SPI1);
            using (var bus = new SPI(device1))
            {
                while (true)
                {
                    bus.Write(new byte[] { 0x02, 0x00, 0x00, 0x40, 0x10, 0xAA, 0xBB, 0xCC, 0xDD, 0x05, 0x09, 0x7f });
                    Thread.Sleep(50);
                }
            }

And setup my Slave on the STM8SVL as such:

SPI_Init(SPI_FIRSTBIT_MSB, SPI_BAUDRATEPRESCALER_2, SPI_MODE_SLAVE, SPI_CLOCKPOLARITY_LOW, SPI_CLOCKPHASE_1EDGE, SPI_DATADIRECTION_2LINES_FULLDUPLEX, SPI_NSS_HARD, 0x07);

Then just a while loop that checks the status of the registers and reads characters from the SPI received buffer.

Any thoughts?

Is the source code for the RGB Led module out there yet? Being a nOOb to writing a SPI slave it seems like from a timing perspective and fast baud rates, a "real" modules we probably need to use DMA?

Help!!!

Kevin…
Kevin D. Wolf
Windows Phone Development MVP
President Software Logistics, LLC
Tampa, FL

#44 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 22 April 2012 - 05:21 PM

I’m fairly sure it’s some sort of timing issue...hmmm, thinking about it, was it because I was debugging and screwing up my clocks?!?!?!

Well, I don't think you can really debug (step into) an on-going SPI transmission, even if you were able to press the key fast enough, the keyboard scan rate is way too slow Posted Image

Usually, I use UART for such diagnostic purposes (dumping a single byte), at high baudrate (e.g. 115200, note the UART_DIV must be greater than or equal to 16 on certain STM8S micros). Then it is probably good idea to store SPI data into a buffer, and use it for further processing (including diagnostic) when the transmission completes, you'd probably need to use asynchronous programming in future versions (SPI interrupt routine). Also, make sure the microcontroller is running fast enough to handle the SPI at selected speed, for example STM8S startup clock is internal oscillator/8 = 2 MHz, which does not give you much time for processing, especially when you need to handle outgoing transmission too. STM8 micros have very few registers, so certain operations, like accessing memory data buffers generate relatively many instructions. CPU running at 2 MHz has only about 10 clock cycles to process one SPI byte at 200 kHz, which is less than 30 instructions, assuming the compiler can emit code that ideally utilizes the multistage pipeline. Debug code for CPU running at 8 - 16 MHz is much better.

a "real" modules we probably need to use DMA?

If the micro has it Posted Image

#45 ByteMaster

ByteMaster

    Advanced Member

  • Members
  • PipPipPip
  • 76 posts

Posted 22 April 2012 - 05:57 PM

Well, I don't think you can really debug (step into) an on-going SPI transmission, even if you were able to press the key fast enough, the keyboard scan rate is way too slow Posted Image


Thanks CW2, yeah, I kind of figured that ;). I was just setting breakpoints after all the SPI "stuff" had finished and looking at the data. I't just ocurred to me while posting there might be additional overhead of the debugger that could be getting in the way...I'll fuss with it a bit more next week, it just seems pretty straight foward.

Do you know if all the STM8x's have DMA available for SPI? I read an app note specific for the STM8L on using it. My searches on the topic didn't help all that much.
Kevin D. Wolf
Windows Phone Development MVP
President Software Logistics, LLC
Tampa, FL

#46 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 22 April 2012 - 06:31 PM

Do you know if all the STM8x's have DMA available for SPI? I read an app note specific for the STM8L on using it. My searches on the topic didn't help all that much.

I don't know all the STM8 variants in detail, but I think DMA is available on STM8L15x. STM8S003 used on Netduino Go! modules does not have it.

#47 ByteMaster

ByteMaster

    Advanced Member

  • Members
  • PipPipPip
  • 76 posts

Posted 22 April 2012 - 06:56 PM

STM8S003 used on Netduino Go! modules does not have it.


Do you know if the source for that firmware has been released anywhere yet?
Kevin D. Wolf
Windows Phone Development MVP
President Software Logistics, LLC
Tampa, FL

#48 ByteMaster

ByteMaster

    Advanced Member

  • Members
  • PipPipPip
  • 76 posts

Posted 24 April 2012 - 01:57 AM

Now for my question/problem. I spent most of Saturday afternoon trying to get the Netduino and STM8 to have a meaningful conversation. It seems like the conversation starts out fine where the first few bytes successfully get sent over. But after that when I read from the STM8’s SP RX register (after checking the receive buffer empty flag) it seemed to the values got out of step. I’m fairly sure it’s some sort of timing issue...hmmm, thinking about it, was it because I was debugging and screwing up my clocks?!?!?!


For most folks building modules it sounds like the Netduino folks have something way easier...but if you really wanna literaly tinker with the bits this stuff is kind-of fun.

Anyway silly Kevin - I was trying to follow some STM8 sample where in a while loop it spun waiting for register status to change and then do an SPI_ReceiveData(), code got "some-what" nasty :P.

Tonight I went with an interrupt handler and life is good!

To start things off I need to initialize the SPI Peripheral with settings that match my SPI Master

SPI_DeInit();	
SPI_Init(SPI_FIRSTBIT_MSB, SPI_BAUDRATEPRESCALER_2, SPI_MODE_SLAVE, SPI_CLOCKPOLARITY_LOW, SPI_CLOCKPHASE_1EDGE, SPI_DATADIRECTION_2LINES_FULLDUPLEX, SPI_NSS_HARD, 0x07);
SPI_Cmd(ENABLE);

Then configure interrupts, I configured the SPI interrupt to fire when the receive buffer was not empty.
SPI_ITConfig(SPI_IT_RXNE,SET);

And then finally enable interrupts on my chip
enableInterrupts();

Then in stm8s_it.c I find the handler for SPI which is on on vector 10 and create my handler.
INTERRUPT_HANDLER(SPI_IRQHandler, 10)
{
	u8 ch;
	ch = SPI_ReceiveData();
	SPI_SendData(ch);
}

This simply takes the byte received from the RX buffer and places it in the TX buffer so with the next clock that byte is sent back to the master.

Soooooo much easier then what I was screwing with over the weekend.

Next up I'm going to tackle how I2C works on the chip.

This getting fun!

-twb

Update: 4/24/2012 - My scope was helpful, but I didn't realize how cheap logic analyzers where getting. I had delivered today a Saleaa 8 channel logic analyzer for $150 from Amazon it's incredible what this thing can do! If you're doing any of this sort of stuff, this would be an excellent investment.
Kevin D. Wolf
Windows Phone Development MVP
President Software Logistics, LLC
Tampa, FL

#49 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 24 April 2012 - 08:32 PM

Honestly, if anyones looking for a module to build, what I'd like to see is an interface board to 3 wire industrial sensors(PNP or NPN). My current project is using a Netduino(not even Plus) with a bunch of transitors, resistors, and relays that are controlled by two push buttons and three industrial sensors(a photodetector and 2 inductive proximity sensors using 4N33 optocouplers to interface to netduino). I'd just worked out the bugs with my proof of concept machine and went to order another set of hardware to work on the next model when I found out about Netduino Go. You can imagine how estatic I was(with limited electronics experience) that the rats nest that is what I need to do to interface with the relays now changed to just ordering 6 relay modules. Then the wiring I had to do with the push buttons gets changed to an incredibly easy to use touchscreen that also allows me to display a lot of diagnostic info and give myself different test modes. My only problem right now is that I need to interface to my photoelectric and proximity sensors. That takes me straight back to my rats nest of optocouplers and resistors. What I'd like to see someone make is a module that gives you as many 3 wire sensor interfaces as possible in one module. Give two screw terminals for the sensor power, then three screw terminals each for as many sensors as you could fit on it. For my application, I'd love to see at least 4, obviously more would be awesome. I guess at the moment I have to use a shieldbase and do it the way I was previously doing it. What really sucks is that I need 6 relays, so until that restriction where you need 4 open module ports on the Go is changed, I can't even use relay modules. The only thing I gain right now is the touchscreen.

#50 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 24 April 2012 - 08:37 PM

Update: 4/24/2012 - My scope was helpful, but I didn't realize how cheap logic analyzers where getting. I had delivered today a Saleaa 8 channel logic analyzer for $150 from Amazon it's incredible what this thing can do! If you're doing any of this sort of stuff, this would be an excellent investment.

Must admit I think the Saleae is a great buy - I've found mine incredibly useful.

Regards,
Mark

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#51 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 24 April 2012 - 10:25 PM

@NXTwoThou We're working on solving many of the issues that you brought up. Please stay tuned. Cheers, -Fabien.

#52 mtylerjr

mtylerjr

    Advanced Member

  • Members
  • PipPipPip
  • 106 posts
  • LocationChristchurch, New Zealand

Posted 25 April 2012 - 12:01 AM

Must admit I think the Saleae is a great buy - I've found mine incredibly useful.

Regards,
Mark


I was just about to buy one of these on Amazon

http://www.amazon.co...A/ref=pd_cp_e_0


With the optional lead kit it seems to a hardware n00b like me to support more channels, at a much higher scan rate, for a cheaper price. I dont have the critical experience to compare the two any further than that though, so any advice would be helpful. (Private messages are fine, so as not to hijack the thread)

#53 mtylerjr

mtylerjr

    Advanced Member

  • Members
  • PipPipPip
  • 106 posts
  • LocationChristchurch, New Zealand

Posted 26 April 2012 - 01:25 AM

Okay, if no one has any feedback, I'll go with the ZeroPlus, with is 100mhz scan rate, 16 channels, 32K per channel, and a couple of free protocols for $114 or so on Amazon.

#54 ItsDan

ItsDan

    Advanced Member

  • Members
  • PipPipPip
  • 101 posts

Posted 26 April 2012 - 02:10 AM

Hopefully in the next few weeks you'll be seeing something new available for Netduino Go. BEHOLD:

Posted Image

Posted Image

These are the prototypes of the prototyping modules Arron and I (mostly Arron) are building. These ProtoModules will let you prototype new modules or connect miscellaneous hardware to your Netduino Go. All the pins on the microcontroller are broken out to standard headers, and there's a prototyping area that includes a 3.3v, 5.v, and ground bus. The final version will accomodate a mini-breadboard.
Follow the adventures of the Box of Crappy Surplus

Total BOCS Traveled Distance: 9708 miles | States Visited: 5
Track the Box

#55 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 26 April 2012 - 06:40 AM

Impressive. IMHO one useful feature would be a dedicated programming connector, i.e. SWIM for STM8 and/or AVR ISP for AVRs, not necessarily populated.

#56 Arron Chapman

Arron Chapman

    Advanced Member

  • Members
  • PipPipPip
  • 289 posts
  • LocationOregon, USA

Posted 26 April 2012 - 08:06 AM

Impressive.

IMHO one useful feature would be a dedicated programming connector, i.e. SWIM for STM8 and/or AVR ISP for AVRs, not necessarily populated.


Because all the pins are broken out, I opted away from adding the extra headers for it, however if there is enough demand, I'll certainly add them.

When you talk EE use small words, I'm just a Software Developer :)
My Blog/Site and Everything Else

If my post helped you please consider pressing the "Like This" button in the bottom right-hand corner.

 

Oh my. So many things, so little money!!

 


#57 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 29 April 2012 - 07:41 PM

Does anyone have the part number for the plugs for making the ribbon cables for the Go modules? Or does anyone have 15 cm cables for sale? I want a 15 cm cable to allow me to run the cable under the display to the mainboard and the extra plug will allow me to make short cables for when the module and mainboard are mounted in close proximity to each other. Thanks, Chuck

#58 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 30 April 2012 - 02:00 AM

Hi carb, I'm not sure if they sell them in single-quantities or not, but you can get custom cables from Major League electronics for sure. http://www.mlelectronics.com/ Chris

#59 ransomhall

ransomhall

    Member

  • Members
  • PipPip
  • 12 posts
  • LocationBurlington, VT, USA

Posted 01 May 2012 - 06:20 PM

For any of you who might need a 10 pin socket to 0.1" header breakout for prototype module development, take a look at my MakeBread module . The data pins are obviously not labelled the same, but the important ones (3.3V, 5V, and GND) are. If there is enough interest, I would be happy to get a batch made with an updated silkscreen.

In regards to the previous posts on this thread about a prototype module dev kit of some sort, I would love to see a breadboard friendly one.

#60 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 01 May 2012 - 07:15 PM

For any of you who might need a 10 pin socket to 0.1" header breakout for prototype module development, take a look at my MakeBread module . The data pins are obviously not labelled the same, but the important ones (3.3V, 5V, and GND) are. If there is enough interest, I would be happy to get a batch made with an updated silkscreen.

In regards to the previous posts on this thread about a prototype module dev kit of some sort, I would love to see a breadboard friendly one.


I like the design of your MakeBread Module. I could definitely see having a handful of them in my lab. Would be very handy.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.