Skip navigation

Arduino

4 Posts authored by: mcb1 Top Member

In November I offered to use an Arduino UNO as a reversing monitor.

Arduino Uno THROWBACK THURSDAY Contest


It's a simple concept

  • Arduino
  • Ultrasonic ping sensor
  • NeoPixel LED's

 

You use the ping sensor to detect the distance and change the colour of the NeoPixel to show Green for safe, Orange for Warning and Red for Stop.

 

In Part 1 ( http://www.element14.com/community/groups/arduino/blog/2016/01/07/ultrasonic-reversing-monitor ) I made this comment :-

 

Part Two

I'm still completing the final parts of the code.

There have been some other distractions (inc silly season) and I want do some more testing on the code.

I have found a suitable enclosure but I need to live test it before I fit it to the enclosure.

 

The Ping sensor uses a Tx and Rx ultrasonic transducer to send out a burst of high frequency audio.

This causes ringing of the transducer and can cause the mounting hardware to resonate which may give false readings.

I've been finding that doing this work in a confined room results in lots of echo, and therefore my "same distance' measurement isn't the same.

 

I've also had some issue with the IDE and the colourisation of keywords, that threw me off for a few days.

 

 

 

Short Distances

I was getting random short distances that made no sense.

I tried slowing down the Ping rate which seemed to help, but not make the problem go away.

 

I tried changing the hardware, using the theory it was faulty, but still I got random values that were short.

 

I tried a new library, various averaging approaches and searched the internet to see if the issue was common.

I found a site where the author used the "Running Median" of several readings, and while the code seemed to work at short distances, anything longer than 1m seemed to cause these random short distance values.

 

In the end I needed to start assembling the hardware in order to take some photos.

During the assembly I followed the instruction here that specified adding a 1000uF capacitor across the NeoPixel power wires.

DSC_8852_01%20(Small).jpg

    100uF instead of the 1000uF   photo source : three minions (me, myself and I)

 

When I next connected the assembled unit to the computer, it behaved perfectly with no short distances.

 

So my conclusion is that while the lack of capacitor didn't impact on the Neopixels, it did manifest in the Ping Sensor which was hanging across the same 5v source.

 

 

Distances

While you can hardcode the distance trigger points, it makes much more sense to allow the user to set their own.

The problem is how do you make something user friendly, and fairly clear while capturing the distance.

 

I elected to use a single pushbutton, and detect it at power-up.

If it is pressed and held at power-up, the display changed to three Green pixels to indicate the SAFE distance is stored when you push the button.


Set_SAFE.jpg Set_WARN.jpg  Set_STOP.jpg

photo source : three minions (me, myself and I)

 

Once you have set the SAFE distance, the display changes to three Blue pixels to indicate the WARN distance when you push the button.

If it is pressed, then the display changed to three Red pixels to indicate the STOP distance is stored when you push the button.

Once it has stored all three values, it returns to normal.

 

 

Why BLUE

When I started I was intending to use Orange for the Warning colour.

NeoPixels will do Orange but the brightness is so much less that I felt you may struggle to see it in bright daylight.

When you send the colour it is in the form of Red value, Green value, Blue value with a range of 0-255.

Hence RED is 255, 0, 0, GREEN is 0, 255, 0 and BLUE is 0, 0, 255 and so it is the next brightest colour available.

 

 

 

Errors

While the display is obvious, if the Ping Sensor is not working, or the distances aren't stored, then the sketch goes into an Error display mode.

I elected to make half the display Red while the other half was blank and alternate at about a 1 second rate.

 

It becomes very obvious there is an issue.

It is not easy to continually detect the Ping Sensor, as the library returns distances greater than the maximum as a zero, just as you get if there is no sensor.

 

I included a blanking routine that if it detected the same distance 120 times (approx. 60 secs) it made blanked the display.

If the ping sensor went faulty this would kick in, and it wouldn't come out of it when you reached the SAFE distance (Green).

 

Hence I think I covered all the errors I could.

 

 

Assembly

This version was done for The Shed Magazine which use this version of Arduino UNO.

It allowed me to connect everything to the pins using female to female jumpers, but the same concept will work for a normal UNO.

 

Enclosure.jpg

Enclosure2.jpg

photo source : three minions (me, myself and I)

 

The case is a food type container from a large retailer and at $2 makes a very suitable enclosure

 

I intend to make another version using a Prototype board to connect to the UNO that element14 kindly supplied


 

 

Did it work

Since my daughter moved out, I don't have a parking issue, but if she returns this would be much better than the "stick that moves" we used to have before.

 

The photos below show the false wall I put in my garage to test it out.

I was very happy with the results.


SAFE.jpg  WARN.jpg  STOP.jpg

photo source : three minions (me, myself and I)

 

Final STOP distance.jpg

 

This is the final distance, and from the drivers seat looks like it is touching.

 

Normally you would be reversing into the garage and having the issue of parking in the right spot, but everyone's needs are different, and this works forward or back.

 

The relative position of the display v the sensor may need changing to suit the vehicle and direction.

I mounted it over to the right to allow viewing in an external mirror.

 

 

 

Code

Attached is the sketch and libraries needed to run it.

There are plenty of comments because later I won't remember why I did xyz, or what I was thinking.

Comments take no room in the compiled code but do make it easier for others to use your sketch.

 

 

 

Enjoy

Mark

mcb1

Ultrasonic Reversing Monitor

Posted by mcb1 Top Member Jan 7, 2016

In November I offered to use an Arduino UNO as a reversing monitor.

Arduino Uno THROWBACK THURSDAY Contest


It's a simple concept

  • Arduino
  • Ultrasonic ping sensor
  • NeoPixel LED's

 

You use the ping sensor to detect the distance and change the colour of the NeoPixel to show Green for safe, Orange for Warning and Red for Stop.

Simple enough .... a few lines of code and its' all sorted.

 

 

What about Safety?

There are no safety issues, you just reverse until the light changes colour.

What safety, nothing will fail.

 

s-l1000(sml).jpg

 

That's the difference between a "Fail to Safe" system and the above assumption.

 

In some cases, the person may not be aware of all the factors, and therefore they assume something.

Neopixels retain the last instruction until you send a new one, or remove the power.

If the Arduino or the data line fails for whatever reason, you have the display showing Green and it never changes.

 

The average user will just think these are lights and if you turn them off they go off.

However as the Engineer designing this system, I know better, and therefore should be designing the system to take the NeoPixels characteristics into account.

 

 

What about the Distance settings?

Having hard coded distance settings is fine, but what happens if you install it in your parents place and they want to change the trigger point.

You could reprogram it with new figures, but what happens if you don't have that capability?.

 

Having the ability to set the distance makes it much more user friendly, but it also brings some other challenges.

You need to store the setting, and read it at startup.

There needs to be a warning if there is no settings read (because they aren't stored or corrupted)

The method of setting the distance needs to be considered, and made user friendly.

 

 

I'm pinging all the time

Pinging constantly is fine, but why wear out the transducer while the car is either not there, or is parked for two weeks.

Since it is ultrasonic is there an effect on animals?

Perhaps this might be great to persuade mice and other rodents to vacate the place, but I'm concerned if domestic pets are troubled by it.

constant_noise.jpg

 

I decided that after 10 seconds of the detecting the same distance, we can reduce the ping rate.

We can drop the ping rate down to once every second, we reduce the wear, but allows for any movement to be detected.

 

We really need to know when the car is returning and the distance is getting less.

Since these can work from 4.5m (14 feet), the first few seconds are likely to be well within the safe distance.

 

 

 

Blank the display

Having the Neopixel stuck on the last distance colour is fine, except it simply wears them out and is not necessary.

It would be much more useful to blank the display while it is in 'sleep' mode.

 

We still ping every second, and if the distance changes then unblank the display.

 

I thought that 60 secs is adequate time to decide the car is staying put, and this becomes the sleep time.

 

 

 

How do I know it's working?

Having a 'heartbeat' is necessary to provide user confidence that its working.

 

 

I elected to make one LED White and cycle it around at a 1 sec rate.

While the display is blank, the same will work, or I could leave it blank and maybe flash the onboard LED.

 

 

For the error warning, I elected to flash half the ring RED, with the rest blank. This alternates at a 1 second (1Hz) rate.

ie the first half is RED while the second half is blank and then it swaps to first half blank, second half Red.

It becomes very obvious something isn't right.

 

 

 

What does this all mean?

What it means is that this device performs the same function ie detects a distance and changes colour.

We have added :-

  • Allow the user to change settings.
  • Provide confirmation it is working.
  • Warn if there is an error.
  • Reduce the wear by reducing the ON time of some parts.
  • Reduce the ultrasonic pollution created by the pinger.

 

 

The hardware remains the same, but the code has grown exponentially.

It might not be the most efficient code (I have stated before I'm not a software programmer), but it includes plenty of comments for anyone to follow.

That helps me later when I think why the .... did I do that, or What was I thinking?

 

It also means the quick simple task has morph'ed into a much longer project, and has consumed far too much time.

 

 

My Advice

If you get into these projects, you need to think of the things that could go wrong and deal with them.

Your time is spent planning how to do xyz, coding it, and working out a means to test it.

 

We've made comments before about Engineering is 90% planning and 10% doing, and this is no different.

The end result is a much better product, that is much safer and more user friendly.

 

 

Part Two

I'm still completing the final parts of the code.

There have been some other distractions (inc silly season) and I want do some more testing on the code.

I have found a suitable enclosure but I need to live test it before I fit it to the enclosure.

 

The Ping sensor uses a Tx and Rx ultrasonic transducer to send out a burst of high frequency audio.

This causes ringing of the transducer and can cause the mounting hardware to resonate which may give false readings.

I've been finding that doing this work in a confined room results in lots of echo, and therefore my "same distance' measurement isn't the same.

 

I've also had some issue with the IDE and the colourisation of keywords, that threw me off for a few days.

 

It's got to the stage where I can start actually testing it, and testing the hardware before fitting it into an enclosure ensures you can determine where the problem is, if it doesn't work as expected.


Hopefully soon I can do part 2 and include the code, and some more details of the project.

edit Part 2 is here http://www.element14.com/community/groups/arduino/blog/2016/01/16/ultrasonic-reversing-monitor-part2

Mark

This is an update from this post http://www.element14.com/community/groups/arduino/blog/2015/04/03/iot-lights




Lights, Holiday and Electronics

 

Earlier in the year Christian and element14 sent me the kit for the IoT Xmas Lights.

http://www.element14.com/community/roadTests/1377

I was unable to enter in the challenge due to other commitments, so when I was offered the kit I promised to add something later.

 

 

Lights

My lights have finally arrived.

I looked around for LED outdoor fittings and was not happy with the options, so I went the Asian sourced bare RGB modules.

 

These are 30W RGB http://www.ebay.com/itm/261414473386

The image below was from the website.

30W_RGB.JPG

          The size is 40 x 40mm across the white area

 

The first difference was the led string is orientated 90 deg to this image, and the tags on the left side cut to seperate the three strings.

It's possible this image represents a single colour version which the seller also provides.

 

Connecting it up

I hadn't placed too much thought when I ordered these, since I could wire them in parallel and drive them as three lights.


There are issues with load balance since current will flow through the lowest resistance module.

The usual solution is to place a limiting resistor in series, but with PWM and current control this sort of defeats the purpose.


After receiving them, I noted that it should be possible to cut the right side, which then seperates each LED string.


I could then wire all three modules in series.

There are issues with this as well, since the resistance of each module will differ, the voltage across (and therefore illuminosity) may differ.


LED's have a linear current v illuminosity curve up until it hiits the knee, where more current doesn't give very much more light.

At high current or fully on, you may never see any difference, but at lower current you might.


What to do ...



Spec Sheet

As with many of these asian sources, the specifications are a little lacking.

I returned to the site to see what there was and found this.


 

TypeVoltageCurrentChipBeam AngleLM
RGB20-35v900mA30Mil120-1401200


So my modules require 900mA and 20-35v across each.

 

In the first scenario where they are in parallel, I'd need to control 2.7A.

In the second scenario I'd need to use 60v - 95v at 900mA to run them.

 

It might have helped if I looked at the Infineon shield specs (and the module specs) before ordering modules.

The shield handles 6-48v max and 700mA average with a peak of 1A ...

It suddenly struck me ... this shield was only going to be able to run one or maybe two in series ...and probably not full current and not full brightness.!


Obviously this wasn't going to work.

minions.jpg



Plan B

A Plan B is always there in case Plan A fails ...


My original intention was to fit three of these in Outdoor housings to illuminate a large concrete outdoor area we have.


Patio.JPG

The house is L shape next to this area, and the original intention was to mount one at the left side, one in the middle and another on the right side just above the bench seat.


Having large bright lights is fine, unless you are looking into them, so having three and facing downwards would provide illumination without being a nuisance.

The bulkhead lights on the walls have a cover half way down, so it washes the wall rather than being a bright object that you look directly at.


So can I change the number and/or location to still achieve the original intent.?



Will two lights work?

To provide the same area of illumination, they would need to be raised.

In order to raise them above the guttering, they need to be mounted on a J pole much like TV Aerials are.


We live in the country, and get clobbered by the North West wind.

The corner faces directly northwest, so sticking them on poles, is almost guaranteed to create noise from the wind around the pole, or the vibrations.

As our bedroom is beside one of these spots, that idea is out of the question.



Change locations

The view from this spot is uncluttered.

West_view.jpg

The lights are more decorative than necessity, so adding poles and mounting for this is not something I want to do.


A future plan is to add a structure to the area where my shadow is, and this would be suitable to add lighting to.

This doesn't exist, but was prewired for the day it does exist. (if I recall exactly where on the concrete to drill the hole ..)



Fit more Bulkheads

This idea has merit, but they currently have the mains wiring coming through the brickwork, so some redesigning to control them would be required.

Adding more bulkheads would have the same issues, but since it is not mains wiring the wire could legally be in the cavity ...


So Plan B is not going to work ...



Plan C

There should always be a Plan C in case Plan A and Plan B fails ...


I could order more shields.

This would allow flexibility in control, but could get rather complicated.

In effect I would need three controls or some form of switch in the APP to decide which lamp you are controlling.


I still wouldn't be able to have them at full brightness (900mA v 700mA)



Lower wattage modules.

The modules are available in 10W or 20W at similar low prices.

 

WattageTypeVoltageCurrentLM
10WRGB9-12v900mA900-1000
20WRGB32-35600mA1800-2000

 

As the specs show, the same current and or voltage problems exist.

 

So my orignal plan to use these with the one Infineon Shield to illuminate the concrete area is not going to work.

 

 

 

However there is a lesson in this adventure.

images.jpg

 

 

READ THE SPEC SHEETS FIRST.

 

9cf163d4695930cc5ec895624aab246b.jpg

 

Mark

Lights, Holiday and Electronics

 

Earlier in the year Christian and element14 sent me the kit for the IoT Xmas Lights.

http://www.element14.com/community/roadTests/1377

I was unable to enter in the challenge due to other commitments, so when I was offered the kit I promised to add something later.

 

 

Lights

I have an idea for the lights, and require to source some High Power LED's which the Infineon Shield can drive.

Most of the existing strings are already voltage controlled (just stick them across 12 v and they are happy).


There have been some great uses, but mine will be for anytime ... providing I can sort out the LED's I want and mount them properly.

Since the intention is for outdoor use, the proper enclosure is part of the design requirement.


 

 

Electronics

One of the neat ideas to come out of the Challenge was the IoT link that Jan and Frederick came up with.

[Christmas Wreath of Things] Internet of Holiday Lights: part 10 - Secret IoT Team Up

[Christmas Tree] Internet of Holiday Lights - Special Feature


They extended the invitation to anyone else

Internet of Holiday Lights: Join the secret IoT Service - open for all

I was able to join in with a few lines of code, and an ethernet plug, and while it is a simple task to light a LED or LED's, it is a waste of the Arduino YUN to just do that.


I plan to use the YUN at a central point and send the data over a RF link to an micro arduino, that will drive the display.

The YUN will also interface to the Lights and allow remote control using a wireless device from my home network.


 

 

 

Display

Some time ago Shabaz produced a fantastic map showing where challengers were situated.

He did it for In The Air and again for Forget Me Not.

 

I thought that lighting up the location when the person is online would be a great idea.

 

 

A simple print onto A4 later, and the penny struck ... some countries are not very large ... PLUS there are two people in one small country (ignoring the wives, children, cats and minions).

challenge-map-blank.png

Hence a 5mm RGB or NeoPixel was just not going to work.

Time for another plan.

 

 

 

Fibre Optic

Everyone knows this is the stuff they send the internet down. 

Fibre_optic.JPG

     Photo source www.orcon.net.nz

Well yes that is true, but those tend to be glass fibres and are a fixed size.

 

Wikipedia has a good summary of most uses here.

Optical fiber - Wikipedia, the free encyclopedia

 

They can be used to illuminate sensitive subjects, since they don't conduct the heat, UV or Infra red and their small size makes them very effective.

Low cost LED technology may have displaced this use in many applications.

 

Some people may know that fibre optics were used on some older automobiles to show the various lights were working.

For the 1968-71 Chevrolet Corvette they ran from a fitting in the light through the wiring loom to the dash and were probably a salesman's delight at the time.

Corvette questions | stevelinden

 

I've used Fibre Optics for Lighting effects in three of our Casino's, and some other locations.

We used 'End Glow' fibres to light up square blocks of plastic, or a device that looked like a normal light bulb. There was fascination amongst the builders when these 'light bulbs' changed colour.

We also did a few Starfield simulations complete with 2-3m long shooting stars. (that is a whole other story)


 

The fibre optic generally used for lighting effects is solid plastic with a coating on the outside, and comes in a range of sizes from 0.75mm to 12mm diameter.

The advantage of the plastic means you can apply heat to the end, which creates a dome or lens shape, and of course you can glue/epoxy it.

 

If I use fibre optics then I have the means to transmit the light to a very small hole in a very small country.

 

 

What colour should I use.

I decided that just having a LED that was ON or OFF, was not going to suffice.

An RGB or even better a NeoPixel LED was the better option.

 

I chose to use some 5mm diffused NeoPixels that I purchased locally from Hadley at Nicegear (www.nicegear.co.nz).

I'll simply attach the fibre onto the top with expoxy or some other method that I'll finalise later in the hardware build.

 

How to Light them.

As I said earlier using the Arduino YUN to drive some LED's is a bit of a waste, and with the map fitted to a deep A4 Picture frame, I might not have room.

Instead I'm going to send the data via RF from the YUN to a micro Arduino mounted inside the picture frame.

This also allows for different powering options, so it can be fitted anywhere.

 

 

Eric Tsai provided us with some very informative posts about sending data using RFM69 Transceiver modules.

Uber Multi Wireless Sensor - smoke, gas, flame, dog barking, PIR movement, light - sensor

 

I used this technique to send Hot Water data back to OpenHAB in the Forget Me Not challenge last year.

http://www.element14.com/community/community/design-challenges/forget-me-not/blog/2014/10/20/eldermon-enocean-external-sensors-graphing

 

 

Data to send

As it stands there are 4 participants in this secret IoT service.

I decided on three different states

Online (Green)

Last 24hrs (Red)

Unknown (Blue)

 

This could be achived with a single 8 bit number ... BUT what happens if someone else joins.

 

During the Forget Me Not challenge, the EnOcean modules were solar powered and worked with indoor lighting as low as 100 lux.

In order to work, they needed to conserve the data transmission so it was sent efficently.


For my purpose I have power, but the display could be battery powered (I haven't decided).


If I simply send any change of state, and then send the state every 5 or 10 mins, the RF transmissions will be minimal.

Once the receiver is awake, it only takes a few seconds to process and send the information to the Neopixels, and it can go back to sleep, where it will be saving battery life.


SO I can send more than a single byte of data.

This also means I could use the YUN for other indication ideas ....


Now that I've formulated the overall concept, and decided on a few of the particulars, its time to put the bits together.


In my next blog, I hope to sort out the RF data transfer protocol and drive the NeoPixels.

I should have sorted out the picture frame, and decided how to get two fibres into this country.


Belgium.png


 

Mark

Filter Blog

By date: By tag: