Netduino home hardware projects downloads community

Jump to content

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

Paul Newton

Member Since 13 Nov 2011
Offline Last Active Aug 12 2016 04:20 PM

#60588 74hc595 Shift Register and PWM

Posted by Paul Newton on 31 October 2014 - 03:42 PM

Hi Iain,


You might want to consider using a PWM chip e.g. TLC 5940

According to the data sheet, you only need 3 pins to write to it, and it will generate 16 channels of PWM for you.

The nice thing is that you should only have to tell it to set a pulse width once, you will not have to keep your program busy clocking out loads of data into the shift registers to keep the motors running at a constant speed. (If you try to generate PWM from a shift register, any interruption in the sending of the data to the shift register could leave your PWM pin high or low for an unplanned period of time. This would cause the motors to slow down or speed up.)


The TLC5490 connections are basically the same as the 74HC595 shift register. Since I know you are trying to reduce the number of pins used, I think you will still want to get the other motor control signals from the shift register, you might consider wiring up the two devices into a chain to keep it at 3 pins, or have the clock and data in parallel, with separate enable lines (4 pins).



  • CW2 likes this

#58309 For slow digital circuits, do I need ground between each wire?

Posted by Paul Newton on 21 May 2014 - 06:08 AM

You would not need to do it for the logic speed, but consider whether those grounds are carrying power between the boards.

If they are, you may still need a few grounds (rather than just one) to ensure they provide a low resistance path between the boards. The fewer grounds the higher the resistance, the hotter they could get, and there would be a voltage differential between the boards which could confuse the logic gates.



#58210 How do I pause a while loop using the onboard button?

Posted by Paul Newton on 18 May 2014 - 06:29 AM

A project I worked on used "m_" to signify "member" - e.g. all the members of the classes had m_ whilst local variables in functions had names names with no prefix.


The great thing about standards and procedures is that there are so many to chose from.

#57288 Pin 13?

Posted by Paul Newton on 02 April 2014 - 06:13 AM



It looks like Pin 13 is a plain digital I/O.

I am basing this on the Mini Pinout card in the Wiki pages that has no special functions listed for pin 13, and the how much current can I draw Wiki page that lists P13 as a digital IO (not a high current one).





Don't you just hate it when someine else gets their answer in while you are typing. :)

#56339 obstacle detection

Posted by Paul Newton on 24 February 2014 - 05:52 PM



I think the GO with a Shieldbase could easily achieve the same, maybe not as cheap but definitely doable.


Cheers Olaf

Yes I agree - Go plus shield base would work fine.

Choice probably depends on final form of the project and price.


#55707 PWM.SetPulse equivalent in .NETMF 4.2

Posted by Paul Newton on 28 January 2014 - 08:09 PM

Hi Anshul,


I am still using the Secret Labs PWM class - your screen shot is for the Microsoft one.

(How did you get to that display? - I tried a few things and could not find it.) EDIT: Found it!


I just ran up a test harness, this builds without errors, but I have not deployed it:

  • Open Visual Studio Express C# 2010
  • click New project
    • Select Netduino Plus 1 Application
    • Set name "Pwm_TestHarness", OK
  • File->Save All
  • From the Solution explorer, Open "Program.cs"
  • Replace code in Program.cs with:
using System;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.NetduinoPlus;namespace NetduinoPlusApplication1{	public class Program	{		public static void Main()		{			// write your code here			PWM secretLabsPwm = new PWM(Pins.GPIO_PIN_D5);			secretLabsPwm.SetPulse(20000, 10000);		}	}}

[color=#ff0000;]PWM class is initially underlined in red[/color]

  • In the Solution explorer, expand references
  • right click on [color=#0000ff;]Microsoft.SPOT.Hardware.PWM[/color] - click remove
  • right click on references, click Add Reference,
  • select [color=#0000ff;]SecretLabs.NETMF.Hardware.PWM[/color] (Bottom of list v4.2.2.0)
[*]Build solution


Hope this is the building block you need to get this going.

I remember this was very frustrating when I did it - Paul

#54970 Trying to measure mA and don't understand what I'm seeing

Posted by Paul Newton on 28 December 2013 - 09:51 AM

Hi John,


Consider a simple LED circuit (battery + resistor + LED).

When you use an LED you add a series resistor to limit the current and set the correct voltage at the LED terminals.

If you started with a 9V battery you would calculate the resistor value for 9 Volts.

If you then changed to a 12V battery, you would use a bigger resistor to maintain the same current through the LED.

Obviously you had to fit a new resistor to get the same current and voltage at the LED.


But, rather than calculating the value, you could have used a voltmeter and a variable resistor to acheive the same thing.

You would connect a voltmeter across the the LED, and then starting with the highest resistance, turn down the resistance until the voltage on the LED was correct.

When the voltage is correct the same current will be flowing through the circuit.

If you added another LED, the voltage would drop because not enough current is flowing to drive both LEDs, and so you would turn down the resistance until the correct voltage was present again. Now there should be double the current.


The Netduinos have linear voltage regulators.

These are basically a transistor and a voltage detector.

The transistor operates as a series resistor whose impedance is controlled by the voltage detector.

The voltage detector measures the output voltage to the circuit (5V or 3.3V), and sets the amount of current through the transistor so that the voltage is correct.

The more current the circuit takes, the lower the voltage - the more the transistor is turned on to compensate.


Ring any bells?

If the supply voltage is increased, the transistor compensates and the same current flows.


There are other types of voltage regulator (not used on the Netduino) - "switching regulators" use a transistor(s) as a switch rather than a resistor. The switch rapidly turns on and off causing current to flow into some combination of inductors and capacitors. Depending on the arangement, this sort of voltage regulator can reduce or increase the output voltage (some are able to do both depending on the input voltage).

Now the regulator is more like an AC transformer: power in = (power out + losses)

So if you have more input voltage, the regulator takes less input current.


Hope this helps - Paul

#54182 Morse code to Text to Speach

Posted by Paul Newton on 20 November 2013 - 07:10 AM

.-- . .-.. .-.. / -.. --- -. .

#52763 DFROBOT Buggy

Posted by Paul Newton on 15 September 2013 - 03:23 PM



Finally I have a working system (apart from a few battery issues).


The Netduino Plus (v1) is connected to a Raspberry Pi using a wired ethernet connection.

The Pi is conneted to my home Wifi using a USB dongle.


I have written some classes in c# that allow me to send status to UDP (for testing I can also send it to debug-print or my SPI LED array).

I have also written a UDP receive class (currently very very simple) that has a thread which listens for UDP commands (stop and start).


On the Pi, I have a Python program configured to run a start up which listens for status from the Netduino over UDP and records the current buggy status (Forward/reverse/turn etc).

The Python script also accepts a TCP connection that can request the current status - the status is returned to the caller as text and an image filename in html.

The TCP message can also send a command (currently just start/stop/shutdown), all three are passed on to the Netduino, but the shutdown command actually makes the Pi turn off - this is really handy as the Pi can't just be shut down by pulling power (rather - it should not).


The Pi has been set up with a web server and PHP (a language that runs on the server). It has two simple web pages and some image files. The first web page uses a tiny bit of PHP to send a TCP request to the Python and it gets back some text and HTML that causes the current status image to be shown.

The first page also has some buttons that launch the second page, whose PHP sends a different TCP message to trigger the sart/stop/shutdown actions.


It has taken a really long time to get all this working, so what I want to do next is cut it all right down to a tutorial/template that can be re-used for other applications.



#52424 Long live the Netduino

Posted by Paul Newton on 28 August 2013 - 06:43 PM

I have started this post a few times now, but it kept ending up as a rant, hopefully this one is balanced.


Having owned a Netduino plus (v1) for a while now, I'm probably a little biased, but I think its a great platform to enjoy building with.


You write your code on the free tools, download it and run it. If you want, you can write it all yourself (my preference) or pull in libraries etc. from the community.


One thing I have noticed is the lack of second hand Netduino's for sale on Ebay (at least in the UK), I was really lucky to pickup a pair of plus 1's just after the plus v2 came out - since then I have never seen another one for sale. I think that means people hang on to them. (Maybe its different in your country......)


Ok, there are some issues; I was forced to upgrade the firmware to fix the ethernet bugs, but it was fairly straight forward. I have found that when things do go wrong, or when you need to tackle something new, we are all using the "same" system - this means that help from this forum (and others) actually helps.


In contrast, I have recently acquired a Raspberry Pi (surprise present). I'm sure you will remember the Pi being launched and it sounded like a Netduino killer - all that RAM, speed and peripherals. Why would anybody ever buy anything else again?


I decided to attach it to my Netduino powered buggy. The idea being that I can connect the two via wired Ethernet (which does not use any extra GPIOs), and have the Pi present an interface to the world over Wifi.


Sounds simple, but the Raspberry Pi is really complicated to setup and use. While I am writing this, I am waiting for the Pi to update hundreds of bits of software I've never heard of - its taking ages. I'm only doing that because the instructions I found to install a web server failed. I can't tell if the instructions were bad, if my Pi is not setup correctly, if its not compatible with the instructions, or anything else. (Several others who followed the same instructions chose to respond to the article with a volley of four letter words because they managed to kill or lock up their Pi - I have never seen anything like that on the Netduino Forums.)


There are just too many varients of OS that the Pi can run, and too many possible packages to chose to run on it, some may or may not run on some OSs, etc. So when you ask or look for help, it seems to me to be very unlikely you will find a solution that works for you.

Even the really simple things are really hard to sort out, like how do I get my code to execute without logging in, or like the Wifi turning off when a live ethernet cable is connected to the Pi - that took many hours of trying different hacks to fix!

Oh, and you can't just turn it off, you need to run a command to turn it off and then pull the power.

I'm starting to rant now!


So all I wanted to say is well done to secret labs for bringing us the Netduino.

I hope there are many more developments in the future.



#52205 5V/12V Relay at 30A

Posted by Paul Newton on 17 August 2013 - 08:00 AM

HI Steve,


I just googled "30A 5V Relay", I found this module on Amazon (UK) for 11.29.

It has an opto-isolator built in so that it can be driven directly from a micro-controller like the Netduino.

The relay contacts are rated at 30Amps 30VDC.

I have not used this part myself, but it looks like it would to the job.


The module above has screw terminals, depending on your application, you might be better off with blade connectors. Many of the relays I saw in my search had these.

Automotive relays might also be a good choice for you since there are lots of high current loads in a vehicle, but you will almost certainly need 12V to drive the coil.


There are always lots of things to consider!

Hope this helps - Paul

#51418 Scale AnalogInput from Vref 1.8v - 30v

Posted by Paul Newton on 14 July 2013 - 12:55 PM

Welcome to the Forums!


I started off thinking about using relays to change the potential divider ratios, but they would be much too big.

Then I thought about using non-inverting op-amps. Here, the feedback resistor would be fixed, but several differnet resistors to ground could be selected using a set of transitors. But I think that will be too complex.

Your idea of digital pots sounds much better if you can get them with the high voltage range you need.


Is there a really simpe solution...

I am guessing that you have a cable between the kit with the potentiometers and the Netduino, and that the operator will know which device has which voltage for Vref:


(I think this idea also fails the size requirement, but) could you have a different input connector for each voltage range?

I am thinking that you could select a set of potential divider resisitors for each Maximum Vref {1.8, 3.3, 5, 12, or 30v}.

Then rather than try and do some clever electronics, just plug into a different socket which changes the resistor between the Ain and potentiometer wiper. The resistor between Ain and ground should be calculated to be common to all ranges.


If you can't have different sockets on the Netduino, could you have an inline adapter for the cable which just inserts a resistor on each wiper and the Vref signal?


I would also consider not connecting the external Vref to the Netduino Vref, and instead connecting it to the 6th Ain. This input can then be measured to determine the full scale of the wiper inputs. I know this loses some resolution when the battery drops - so this might not be acceptable. If it is not acceptable, then you are going to need some sort of active circuit because I am sure that the 1.8V Vref is too small for the Netduino Vref input.


Hope these random thoughts help - Paul

#50140 Detect power loss on VIN

Posted by Paul Newton on 31 May 2013 - 06:01 AM

Hi Slackbits, Welcome to the forums. Sorry no one replied to your first post. I think the only thing left to say is that the inputs are 5V tolerant. So whilst you can't measure a voltage above 3.3V, you will get a fullscale reading. Yes, since you just need an ON/OFF signal, you can use a digital IO. You will be able to use an interrupt (event) too. The strange readings you recorded will occur when the analogue inputs are left to float, but you added a potential divider, so there must be some current leaking from other places in the power circuit when the barrel is not connected. It might be worth pulling all the other analogue inputs low using a resistor - this can also help clean up the voltage readings. Good bit of detective work and thanks for feeding back your answer to the forum. Have fun - Paul EDIT: Looks like I was wrong to say the analogue inputs are 5V tolerant. The pins are 5V tolerant when they are configured as digital IO, but once they are set to analogue they are not. I hope I have not used up all my luck! See discussions below.

#49310 Connecting 12 v LED and a push button

Posted by Paul Newton on 09 May 2013 - 09:43 PM

The transistor serves two purposes, it allows a higher current to flow in the load (the LED), and it allows a higher voltage to be present. By dropping down to a few milliamps AND using 3.3V, you can eliminate the transistor. You may want to check what current the LED uses with 12V (before dismantling). Depending on the type, it may be more than the 5mA suggested by Hanzibal. Many of the high brightness ones do only need a few mA to give "normal" brightness, but others need more (20mA is a typical figure). Knowing that current will tell you whether a transistor is needed (there is wiki page giving max GPIO currents), and what value resistor to use. Have fun - Paul

#49302 Connecting 12 v LED and a push button

Posted by Paul Newton on 09 May 2013 - 06:04 PM

One other thing to consider, the LED will have a resistor calculated for 12V, if you are able to pull apart the LED housing you should be able to change the resistor for a lower resistance - this would allow you to use a lower voltage (e.g. 5V or 3.3V). You would still need a transistor as Hanzibal described, but no extra 12V power supply. Hope this helps - Paul

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.