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

Serial port / Project Help


  • Please log in to reply
15 replies to this topic

#1 Thomas Mason

Thomas Mason

    Member

  • Members
  • PipPip
  • 26 posts

Posted 03 November 2012 - 02:09 AM

Hello All,
I have a group at my work and we are working on a lighting display for our office. we are looking at different ways to control up to 32 channels of 120v lights, that will be synced with some music. For this project I am looking to use a laptop to control the lights via some controller. I have looked at just using usb relay boards, but since I already have a Netduino I want to use it and a relay sheild such as this one because it would be cheaper (plus Netduino is much funner right). My question is basically that I am looking for advice as to what would be the best way to communicate with the Netduino in order to send commands. I need to control 32 channels so I will be using some shift registers to accomplish this but how could I send command to the Netduino. Can I do it via USB or does some one have a better way (this is a standard Netduino not the plus).

If any one has some advice on this ... or any other part of the project I would appreciate it.

To be more specific i have read post such as these speaking of serial ports on the device. The question I have is how do I attach to these IE: can i just use a serial cable or is there something special I should know. I am pretty sure I can handle the .net side I am just worried about the physical hookup.

#2 caEstrada

caEstrada

    Advanced Member

  • Members
  • PipPipPip
  • 84 posts

Posted 03 November 2012 - 05:19 AM

Thomas, Welcome OnBoard :D What about using Ethernet? Ethernet is a common in many environments and from my experience, very stable in Netduino Plus. I have some code ready and tested if you need it. Regards, Carlos A. Estrada

#3 Thomas Mason

Thomas Mason

    Member

  • Members
  • PipPip
  • 26 posts

Posted 03 November 2012 - 01:46 PM

Thomas,

Welcome OnBoard :D

What about using Ethernet? Ethernet is a common in many environments and from my experience, very stable in Netduino Plus. I have some code ready and tested if you need it.

Regards,

Carlos A. Estrada


Thanks for the reply Carlos! However as I said I do not have a plus I just have gen one Netduino, so ethernet is not an option for me.

#4 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 03 November 2012 - 09:24 PM

Hi Thomas,

The relay card looks like it needs one GPIO per relay, so you will need to use some logic to control more than one set of 16 lamps.
Using the 74HC595 shift registers is a really easy way to do this - see the Wiki for examples.

You might want to consider using Solid State Relays "SSR"s instead of normal mechanical relays. Mechanical relays will wear out if you are using them to flash lights on and off a lot (e.g. in time to music). They also create electrical noise when they switch which can cause interference to other equipment. SSRs will often include a zero crossing circuit that mean they switch on when the AC voltage passes through zero - this reduces any noise.

Connecting to the PC will be straight forward using a serial port. Assuming you don't have a "state of the ark" PC like mine, you will probably need a USB to serial adapter. Older PCs came with a serial port as standard.
I would always recommend devices from FTDI for USB interfacing, professionally I have found them to be very reliable. They have a set of chips that do the job, and sell cables with bare wire ends to connect to your device. There are two obvious options, USB to RS232 and USB to TTL.
If you go for USB to TTL, you will not need to use any other hardware. (Chose a 3.3V compatible part.) The TX and RX lines just connect to the Netduino's Rx and TX lines.
If you go for USB to RS232, you will also need a level converter at the Netduino. There are plenty of level converters around to chose from. The benefit of using RS232 is that you will be able to use a longer cable, and it would allow other configurations in the future if you move away from the PC with USB design.
(There would be no difference in the software you write.)

Hope this helps - Paul

PS if you use Android - disable the auto update option. Chrome decided to update on me half way through typing this response. I lost the lot and started again using a laptop.


EDIT: Just spotted on the link you gave that the relay card needs 15 to 20mA per input. The Netduino digital IOs have different limits and only three of them can source the maximum 16mA. Hence you will not be able to drive the relay card directly without using either transistors or a device like the 74HC595. See the Wiki page on how much current can be drawn from IO lines.

#5 Thomas Mason

Thomas Mason

    Member

  • Members
  • PipPip
  • 26 posts

Posted 04 November 2012 - 12:43 AM

Agreed on the solid state but they are more expensive by a large margin. So then if I cascade som shift registers I can get it done sounds good. Where can I find info such as which ports on the netduino can provide which amperage ? Sorry you already answered that. But how will the shift register help with amperage?

#6 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 04 November 2012 - 10:05 AM

Hi Thomas,

Whilst the Netduino is quite limited in the amount of current it can supply on each of its IO pins, the shift register chip's IO pins can drive the current needed for the relay board inputs (in the 74HC595 data sheet, it states up to +/- 35mA).

Just like the Netduino, there is still a limit on total current that can be taken by the chip. I was surprised to see this is 70mA in the data sheet I just read - I have happily been driving 8 LEDs from these chips for some time now without any problems.

Also since the shift register chips have their own supply voltage input, you could power them from the relay's 5V regulator. This will reduce the current taken from the Netduino and hence allow its regulator to run cooler. If you chose to draw lots of current from the 5V output on the Netduino, the regulator would get hot. Its only quite a small one, so this is best avoided.

Paul

EDIT:

I added a diagram of the two channel relay card input on the other forum page.
The supply current for the LEDs in the opto-isolators appears to come from the relay board, the external circuit provides a path to ground for the LED current. This current to ground is still to high for the Netduino pins to sink directly.

Sorry for any confusion

#7 Thomas Mason

Thomas Mason

    Member

  • Members
  • PipPip
  • 26 posts

Posted 04 November 2012 - 01:33 PM

So my goal is to drive two of these relay boards for a total of 32 channels. I will need to cascade 4 shift registers to get this done. Would you say that I can drive this directly off the netduino ? If not what would my alternative be transistors?

#8 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 04 November 2012 - 06:09 PM

Yes you can drive all four of these off the Netduino. The shift registers will handle all the current, they will only draw a tiny amount of current from the SPI signals (clock, data and strobe/latch). Assuming the circuit diagram I found for the dual relay board is also a match for the input stage of the 16 relay board, then the shift registers only need to sink current to ground - not source it from Vcc. Hence there will also be no problem supplying 5V to shift register Vcc pins from the Netduino 5V output. Paul

#9 carb

carb

    Advanced Member

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

Posted 04 November 2012 - 06:51 PM

So my goal is to drive two of these relay boards for a total of 32 channels. I will need to cascade 4 shift registers to get this done. Would you say that I can drive this directly off the netduino ? If not what would my alternative be transistors?


Thomas,

You may want to look at this shield, it is made by a membeer of this forum. Multiplexor shield

I have one that I put together but have not used yet. The price was right.

Chuck

#10 Thomas Mason

Thomas Mason

    Member

  • Members
  • PipPip
  • 26 posts

Posted 04 November 2012 - 07:18 PM

Thomas,

You may want to look at this shield, it is made by a membeer of this forum. Multiplexor shield

I have one that I put together but have not used yet. The price was right.

Chuck

Thanks for the reply Chuck that link led me to some good info on hooking up the shift registers as well.

#11 Thomas Mason

Thomas Mason

    Member

  • Members
  • PipPip
  • 26 posts

Posted 05 November 2012 - 12:38 AM

Hi Thomas,

The relay card looks like it needs one GPIO per relay, so you will need to use some logic to control more than one set of 16 lamps.
Using the 74HC595 shift registers is a really easy way to do this - see the Wiki for examples.

You might want to consider using Solid State Relays "SSR"s instead of normal mechanical relays. Mechanical relays will wear out if you are using them to flash lights on and off a lot (e.g. in time to music). They also create electrical noise when they switch which can cause interference to other equipment. SSRs will often include a zero crossing circuit that mean they switch on when the AC voltage passes through zero - this reduces any noise.

Connecting to the PC will be straight forward using a serial port. Assuming you don't have a "state of the ark" PC like mine, you will probably need a USB to serial adapter. Older PCs came with a serial port as standard.
I would always recommend devices from FTDI for USB interfacing, professionally I have found them to bei very reliable. They have a set of chips that do the job, and sell cables with bare wire ends to connect to your device. There are two obvious options, USB to RS232 and USB to TTL.
If you go for USB to TTL, you will not need to use any other hardware. (Chose a 3.3V compatible part.) The TX and RX lines just connect to the Netduino's Rx and TX lines.
If you go for USB to RS232, you will also need a level converter at the Netduino. There are plenty of level converters around to chose from. The benefit of using RS232 is that you will be able to use a longer cable, and it would allow other configurations in the future if you move away from the PC with USB design.
(There would be no difference in the software you write.)

Hope this helps - Paul

PS if you use Android - disable the auto update option. Chrome decided to update on me half way through typing this response. I lost the lot and started again using a laptop.


EDIT: Just spotted on the link you gave that the relay card needs 15 to 20mA per input. The Netduino digital IOs have different limits and only three of them can source the maximum 16mA. Hence you will not be able to drive the relay card directly without using either transistors or a device like the 74HC595. See the Wiki page on how much current can be drawn from IO lines.


So if I have a serial port do I need an special equipment or can I just plug the wires into the netduino?

#12 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 05 November 2012 - 06:54 AM

So if I have a serial port do I need an special equipment or can I just plug the wires into the netduino?


Sorry - no
If you have an RS232 serial port on the PC, you will need an RS232 to TTL converter.
There are plenty of ready built modules out there to chose from.
Some come with a 9-way D-Type cionnector fitted, some are just ready for wires to be soldered on.

Without an RS232-TTL adapter, the serial data will be the wrong voltage and inverted when the Netduino receives it; nothing will make much sense.

Paul

#13 Thomas Mason

Thomas Mason

    Member

  • Members
  • PipPip
  • 26 posts

Posted 05 November 2012 - 04:38 PM

Sorry - no
If you have an RS232 serial port on the PC, you will need an RS232 to TTL converter.
There are plenty of ready built modules out there to chose from.
Some come with a 9-way D-Type cionnector fitted, some are just ready for wires to be soldered on.

Without an RS232-TTL adapter, the serial data will be the wrong voltage and inverted when the Netduino receives it; nothing will make much sense.

Paul


Hey paul I have a strange question which you may or may not know the answer to. APC ups have a USB to serial cable that they use communicate but this cable only puts out 5v and it does not apear to be a 232 cable. Is it possible this is a TTL cable ... is there any way to tell by looking at it ?

#14 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 05 November 2012 - 06:31 PM

Yes, it could be TTL. A few thoughts: Best would be to look at the signals fromthe USB adapter with an oscilloscope - see if they go positive and negative. The negative is a giveaway that it is RS232. An RS232 adapter will idle at negative volts - about-5V with respect to ground. If you are seeing +5V that sounds more like a TTL one. I assume you are using a voltmeter - have you got the wires the right way round? You might actually have found -5V. How many wires are there? The 5V you are seeing might be a power rail - not data. If you have a PC with a real RS232 port, connect the output from the USB adapter to the the PC's pin 2 (on a 9-way D-Type male connector), best to get a friend to help hold the wire. Open up a pair of hyper-terminals and try and send some characters from the USB comm port to the RS232 one. (configure with no flow control) If you get sensble characters, it is RS232. (Putting TTL levels into a real RS232 port will not damage either end - putting RS232 -v.e. volts into a TTL/CMOS device could damage the TTL/CMOS device.) Get your Netduino to send out a stream of characters and touch the Netdunino TX line onto the adapter's rx line (also connect ground) and see if you receive the correct characters on the PC. If you do, its TTL. Paul

#15 Ahmed Atlam

Ahmed Atlam

    New Member

  • Members
  • Pip
  • 3 posts
  • LocationCairo, Egypt

Posted 12 November 2012 - 04:52 AM

Hey guys ! As long as we are talking about serial interface, I am having a strange problem with my netduino + I am using serial to send data back and forth from a PC (very standard), using sparkfuns FTDI board. The netduino can receive data no problem (test was to turn on/off the on board LED on command) however it cannot send any data to the PC. I am sure I have the wiring right, I am sure I have the Jumper on the FTDI board set to 3.3 V (even measured voltage with meter). I was so frustrated that I had the netduino send data on interrupt from SW and scoped Tx ( on COM1 thats D1) ... There was nothing on the scope ... D1 is dead !! It works fine as an Inputport/OutputPort/InterruptPort but no serial. (same case for COM2 ie: D3) Am I missing something ? Do I need to enable something ? Please advise ANY help is appreciated !!! Even if its a confirmation that my Netduino+ is broken and needs to be replaced, I am going nuts here !!! Thanks alot !!! Ahmed

#16 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 12 November 2012 - 06:54 AM

Hi Ahmed, If you're not getting TX data on either COM1 or COM2, I'm guessing it's a code issue. Can you please share a snippet of your code, and we can help diagnose? If your wiring was providing dangerous voltages to the TX pins, it's possible that they got damaged. But it's a fairly remote likelihood. Let's look at the software first. Also, just to make sure...you're not using any flow control correct? Chris




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.