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

Help schematic first atempt


  • Please log in to reply
37 replies to this topic

#1 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 02 October 2011 - 12:21 PM

Hi,

I am trying to make an aquarium controller, the basic idea is that it will do the following:

Wifi web controlled via a gainspan wifi module (serial com1)
Will keep time with a ds1307 breakout board (scl/sda)
Will display data on a sparkfun serial graphic lcd (serial com2 shared)
Take ph readings with an atlas scientific ph stamp (serial com2 shared)
Temperature readings using ds18b20's (1-wire com2 shared)
There will be extra outputs using 74hc595's (cs on pin 9)
6 SSR relays controlled from sone of the outputs from the 74hc595's
Com2 will be multipled using a 74hc4052 and this will be swithed using some output from the 74hc595's
There will be extra inputs using 74hc165's which may be used for input devices like a keypad. (cs on pin 10)
Data will be logged using a sparkfun microSD shield (cs on pin 8)

This can all be seen on my first attempt of a schematic which can be seen on the link at the bottom, the idea is that this will be like an oversized shield so this will sit on top of the sd shield.

I would really appreciate it if someone could help me work out how to get 2 daisychained tlc5940 pwm expanders in to the schematic to control led lighting, a few fans and a solenoid valves. Also if anyone can see any mistakes?

I have drawn the schematic using DesignSpark PCB and I can provide the projet file if it is any help.

Many thanks,

Andy

http://2.bp.blogspot...00/Aquarium.bmp

#2 Nevyn

Nevyn

    Advanced Member

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

Posted 02 October 2011 - 03:13 PM

I would really appreciate it if someone could help me work out how to get 2 daisychained tlc5940 pwm expanders in to the schematic to control led lighting, a few fans and a solenoid valves. Also if anyone can see any mistakes?

I have drawn the schematic using DesignSpark PCB and I can provide the projet file if it is any help.

What problems are you having with the TLC5940 - I'm using one of these at the moment and I finally got it working last night. I'm just starting to refine the circuit so that it will do what I want it but better.

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


#3 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 02 October 2011 - 04:14 PM

What problems are you having with the TLC5940 - I'm using one of these at the moment and I finally got it working last night. I'm just starting to refine the circuit so that it will do what I want it but better.

Really? I got it in front of me as well :D
Working on a library for it as we speak; wanna do it the same way as my 74hc595 lib.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#4 Nevyn

Nevyn

    Advanced Member

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

Posted 02 October 2011 - 04:31 PM

Working on a library for it as we speak; wanna do it the same way as my 74hc595 lib.

The SPI data transfer was the easy bit. I'm just working on trying to get fgsclk sorted out along with the corresponding BLANK signal. Got it working but only up to 71kHz using the Netduino to control BLANK but I want to get a 1 MHz circuit working. The Netduino is unlikely to be able to keep up at that rate.

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


#5 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 02 October 2011 - 04:51 PM

Andy, could you post the schematic using a better resolution? I really cannot read anything... Try to convert it as JPEG or PNG, if takes too much bytes. Thanks!
Biggest fault of Netduino? It runs by electricity.

#6 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 02 October 2011 - 07:11 PM

Hi, I have attached it as a pdf it was the only way I could get a decent resolution so I hope this helps. Basically my problem is that I am using the spi for 3 things currently; the 595's for outs, the 165's for ins and the sd sheild, using cs 9,10,8 respectively. So I am a little unsure on how I can connect in the tlc5490's to work with this. I guess there will be some changes to the lib's for bit shift stuff stefan? Thanks for the help and I look forward to a little guidance with the libraries with this, writing classes for hardware is what I really want to learn to get my head around at the moment but don't really know where to start from getting a chip and it datasheet, to writing a library to control it. Thanks again, Andy

Attached Files



#7 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 02 October 2011 - 07:48 PM

I guess there will be some changes to the lib's for bit shift stuff stefan?

It will only be expanded, but I don't know when it's done, it's a difficult one! I got it working but with performance issues; managed SPI has got a hard time with it ;)
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#8 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 02 October 2011 - 08:34 PM

I've worked out how to create a component in designspark now, so I have the tlc5490 ready to draw in to my schematic, bare in mind I am using stefans bit shift example using pins 9 and 10 for cs and the sparkfun microSD is using pin 8 for cs and, all share the spi 11 - 13, what pins would I connect the tlc 5490 to? Also as can be seen on the attempt of a schematic I have serial com1 going to the gainspan and the com2 serial is split for ph, lcd and temp using a 4052, there is one free channel on the 4052. Thanks Andy

#9 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 02 October 2011 - 09:09 PM

I've worked out how to create a component in designspark now, so I have the tlc5490 ready to draw in to my schematic, bare in mind I am using stefans bit shift example using pins 9 and 10 for cs and the sparkfun microSD is using pin 8 for cs and, all share the spi 11 - 13, what pins would I connect the tlc 5490 to? Also as can be seen on the attempt of a schematic I have serial com1 going to the gainspan and the com2 serial is split for ph, lcd and temp using a 4052, there is one free channel on the 4052.

For now, you could use the library mentioned at http://dotnetdave.ne...th-the-tlc5490/

The connections I have:
GSCLK -> pin 7
DCPRG -> +5V
IREF -> GND
VCC -> +5V
GND -> GND
BLANK -> pin 10
XLAT -> pin 9
SCLK -> pin 13
SIN -> pin 11
VPRG -> pin 8
Don't forget to add a resistor for each led though! I use resistor networks for that.

Initialize it like:
Tlc5940 ic = new Tlc5940(Pins.GPIO_PIN_D13, Pins.GPIO_PIN_D11, Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D7);
ic.Init();

The library doesn't use managed SPI, which has a few downsides:
- The pins 11 and 13 can't be used by other SPI-devices at the same time
- Performance is a bit low since it's bitbanged

But hopefully you can get a bit creative and get something working out of it anyway :D
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#10 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 02 October 2011 - 11:04 PM

Hi, Thanks Stefan, will the above work with the other devices using 8, 9 and 10 as chip select? My knowledge of what can and can't be done is some what limited. :huh:

#11 Nevyn

Nevyn

    Advanced Member

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

Posted 03 October 2011 - 05:51 AM

Don't forget to add a resistor for each led though! I use resistor networks for that.

Initialize it like:

Tlc5940 ic = new Tlc5940(Pins.GPIO_PIN_D13, Pins.GPIO_PIN_D11, Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D7);
ic.Init();

The library doesn't use managed SPI, which has a few downsides:
- The pins 11 and 13 can't be used by other SPI-devices at the same time
- Performance is a bit low since it's bitbanged

You don't need a resistor network if you use the IREF pin. Drop a resistor between IREF and ground according to the following formula:

R = (1.24 * 31.5) / Imax

Imax is the maximum current per pin.

This assumes that all devices connected to the chip can operate with the same maximum current.

I'm interested in why you aren't using SPI because unless I have misunderstood my results this appears to work OK. Alright, you do not use CS on the chip but it does work.

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


#12 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 03 October 2011 - 06:01 AM

This assumes that all devices connected to the chip can operate with the same maximum current.

Indeed, an assumption ;) I prefer to just use a resistor linked to each led, since it's easier to understand though.

I'm interested in why you aren't using SPI because unless I have misunderstood my results this appears to work OK. Alright, you do not use CS on the chip but it does work.

It's not my library, I just linked it to help out, but still, I'm curious to 'your way'. Lets discuss that over with a pm :)
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#13 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 03 October 2011 - 06:13 AM

Thanks Stefan, will the above work with the other devices using 8, 9 and 10 as chip select? My knowledge of what can and can't be done is some what limited. :huh:

Nope, not yet. But we'll find a way, I know your a patient guy (luckely :D)
Both Nevyn and I are tinkering with it and I just sent him a PM to combine our strength. Hopefully we can create a steady base to work with for those IC's.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#14 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 03 October 2011 - 07:06 AM

I agree with Mark about the TLC SPI. To drive the TLCs (which may be chained), the SPI appears pretty simple to use. The SS is the XLAT line. You only need an extra output for the VPRG line, which cannot derived from anything else. Also the BLANK could be tied low all the time, as long the DCPRG which should be tied high. The GSCLK should be driven by any PWM output (duty 50%) of the Netduino, so that the signal will be a square wave. I may suggest a frequency relatively high, let's say 10MHz, but I don't know what the Netduino PWM can do. Andy, some points: - are you going to use a particular firmware for the 1-wire protocol? - why are you using two different lines to drive the 165? you need only one SS=/PL, similarly to the 595. - it seems that there some free I/Os in the Netduino: why are you deriving the extra lines from the 595? Cheers
Biggest fault of Netduino? It runs by electricity.

#15 Nevyn

Nevyn

    Advanced Member

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

Posted 03 October 2011 - 07:20 AM

The SS is the XLAT line.

I was starting to wondr about that point last night but did not have the time to test if it would work OK.

The GSCLK should be driven by any PWM output (duty 50%) of the Netduino, so that the signal will be a square wave. I may suggest a frequency relatively high, let's say 10MHz, but I don't know what the Netduino PWM can do.

I never thought about using the PWM on the Netduino for GSCLK - may have to give that a try. I have been investigating using an external clock built using a resonator (accuracy is not that important here). I'm having no luck in getting this working on breadboard - I've tried a resonator and a crystal running at 4MHz and I get nothing out of the circuit. I'll open another thread for this subject.

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


#16 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 03 October 2011 - 07:52 AM

Hi mario, I have moved to 4.2 as I was having to many issues, so I am waiting for chris to get chance to make a one wire verion, I will just leave out the 1-wire code for now. The 595s are to control a number of relays and things like autofeeders eventually, also I use some of the 595 outs to supply 3 digitals to control the 4052. The 165's are there for future expansion, maybe a keypad and auto top up switch etc. I was thinking I would need to use a pwm port to control the 5940, I had a quick read of the datasheet last night to try to understand it a little more, apparently it can work off 3pins? Serial I think? Also if you need to suppy a square wave to set the frequency for it, I can't remember exactly but I thinkk it mentioned something around 32Mhz in the datasheets, couldn't you use the crystal the drives a ds1307 realtime clock like the one I have? I notice the rtc breakout has a pin called "SQW" which I am assuming is a square wave out? I guess the higher the squarewave the better the resolution? Thanks for the help guys Andy

#17 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 03 October 2011 - 12:07 PM

I have moved to 4.2 as I was having to many issues, so I am waiting for chris to get chance to make a one wire verion, I will just leave out the 1-wire code for now.

Okay, I never tried it.

The 595s are to control a number of relays and things like autofeeders eventually, also I use some of the 595 outs to supply 3 digitals to control the 4052.

Consider this thread first.

The 165's are there for future expansion, maybe a keypad and auto top up switch etc.

Okay.

I was thinking I would need to use a pwm port to control the 5940, I had a quick read of the datasheet last night to try to understand it a little more, apparently it can work off 3pins?

Not sure about the meaning of "it can work off 3pins" (sorry!), but -at least- it requires the SPI wires (SCLK, MOSI, SS) and a 4th wire (VPRG) for switching between the Grayscale- and the Current-mode.

Serial I think?

Right, but synchronous only. The UART cannot work.

Also if you need to suppy a square wave to set the frequency for it, I can't remember exactly but I thinkk it mentioned something around 32Mhz in the datasheets, couldn't you use the crystal the drives a ds1307 realtime clock like the one I have?

The oscillator (crystal) of the RTC is 32 KiloHertz, not MegaHertz.
The TLC requires that clock (GSCLK) to generate the duty-cycle by counting up to the programmed limit.
Since the resulting PWM frequency out would be -generally- as higher as possible, the GSCLK should also be high enough.
For instance, if you feed the GSCLK with 1 MHz, the PWM out should be 1E6/4096=244Hz. I am NOT sure about this point, but that's what I understood this morning by reading the specs.
Anyway, if I understood right, 244Hz is too slow. If you have to drive a bulb or a heater, it can be even too fast, but if you have to control a motor (e.g. a servo), maybe you will need a higher frequency.

According to the specs, you may feed the GSCLK up to 30MHz. However, 30MHz is maybe too high if you don't know how to deal with stray capacitance, long wiring, impedances, etc. I'd suggest to keep the frequencies under 10MHz at most.

Mark suggests correctly to generate the clock from a crystal or a ceramic resonator. It's the most straightforward way, but it requires several components more (and your board is already plenty of them!)
The Netduino PWM output can generate a square wave for "free", because there's no need of any extra hardware to achieve it. Now, I don't know what are the actual limitations I heard about the PWM. If you will able to generate a PWM frequency of several MHz, and having a duty cycle of 50% (not mandatory, but better), you've done!

I guess you should make some experiment on a bread board with the TLC before closing the whole circuit: it is worthwhile.

I notice the rtc breakout has a pin called "SQW" which I am assuming is a square wave out? I guess the higher the squarewave the better the resolution?

That's very useful, and it's a pity that none consider it a bit better!
However, I'd choose the NXP PFC8583 over the Dallas RTC. It's much more versatile, uses the I2C, more RAM, and an useful programmable-alarm output. There are plenty of ideas around it!
Cheers
Biggest fault of Netduino? It runs by electricity.

#18 mcinnes01

mcinnes01

    Advanced Member

  • Members
  • PipPipPip
  • 325 posts
  • LocationManchester UK

Posted 03 October 2011 - 07:44 PM

Can you recommend what crystals/ resinator would best and any other components? As mentioned I plan on using this for various pwm applications simultaneously, from solenoid and fan control, to the main function which will allow me to create a really realistic aqaurium lighting fuction. The idea will be that it is dimmable (smooth I want a high resolution), will have a few colors and allow some strobing for lightening effects. I am planning on daisy chaining at least 2 of these and will ideally be using some high power leds like 3watt luxeon stars (not looked in to this yet can anyone recommend anything and transistors? or whatever would be used to switch them?) Thanks again, Andy

#19 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 04 October 2011 - 04:07 AM

About the oscillator Mark has just created this thread.

I don't know whether this strip could fit your idea, but it seems perfect for an aquarium.

If your have to drive requiring enough current, you must use a transistor or a mosfet. Of curse you must use a decent power supply.
For instance, if you were driving this 5W/700mA LED, the very best way is to create a current regulator, NOT a voltage regulator. Since the LED works upon the current flowing into it, if you have a voltage (e.g. 12V) you must insert a resistor to limit the current, and that's a waste of energy. This particular led drops about 7.5V at 700mA, so the resistor will be R=(12-7.5)/700m=6.4 Ohms, but also wasting P=700m*700m*6.4=3.15 W of heat on it!!!
Instead, if you use a PWM current regulator, almost everything you get from the supply is actually used: nothing is wasted.
However, the circuit is more complex.
Cheers
Biggest fault of Netduino? It runs by electricity.

#20 Nevyn

Nevyn

    Advanced Member

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

Posted 06 October 2011 - 07:36 AM

I've worked out how to create a component in designspark now, so I have the tlc5490 ready to draw in to my schematic,

Any chance you could make this component available to the community - I could do with this so I can post a schematic to the work I have been doing.

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





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.