Initial experiments with Bluetooth and Arduino

A place for discussing battery-electric locomotives, whether they're diesel, steam or even electric outline
User avatar
philipy
Moderator
Moderator
Posts: 5033
Joined: Sun Jan 30, 2011 3:00 pm
Location: South Northants

Re: Initial experiments with Bluetooth and Arduino

Post by philipy » Thu Jul 04, 2019 10:09 am

Rik, not sure if you are interested ( it's not Arduino or Bluetooth!) but I've just found a long and detailed thread, with code, for using NRF240L01+ with Picaxe, on the Picaxe forum.
https://picaxeforum.co.uk/threads/using ... les.19036/
Philip

User avatar
ge_rik
Administrator
Administrator
Posts: 6497
Joined: Sun Oct 25, 2009 10:20 pm
Location: Cheshire
Contact:

Re: Initial experiments with Bluetooth and Arduino

Post by ge_rik » Fri Jul 05, 2019 8:26 pm

philipy wrote: Thu Jul 04, 2019 10:09 am Rik, not sure if you are interested ( it's not Arduino or Bluetooth!) but I've just found a long and detailed thread, with code, for using NRF240L01+ with Picaxe, on the Picaxe forum.
https://picaxeforum.co.uk/threads/using ... les.19036/
I might well be interested later on. For the moment I'm still exploring Bluetooth, but when I've got as far as I want to with it, I'll start exploring more traditional RC including the nrf240 and maybe even using the Bluetooth module in a tx with knobs and switches.

Rik
------------------------
Peckforton Light Railway - Blog Facebook Youtube

User avatar
philipy
Moderator
Moderator
Posts: 5033
Joined: Sun Jan 30, 2011 3:00 pm
Location: South Northants

Re: Initial experiments with Bluetooth and Arduino

Post by philipy » Sat Jul 06, 2019 2:26 pm

ge_rik wrote: Fri Jul 05, 2019 8:26 pm when I've got as far as I want to with it, I'll start exploring more traditional RC including the nrf240 and maybe even using the Bluetooth module in a tx with knobs and switches.
Subsequent to my post I found a site of a guy who has got arduino, and the Tx-Rx 2.4gh modules, with speed knobs and steering joysticks , working for R/C cars, Should be easy to swap switches for joysticks and use them for bells and whistles instead of steering. Let me know if you want the links.
Philip

User avatar
ge_rik
Administrator
Administrator
Posts: 6497
Joined: Sun Oct 25, 2009 10:20 pm
Location: Cheshire
Contact:

Re: Initial experiments with Bluetooth and Arduino

Post by ge_rik » Mon Jul 08, 2019 10:34 am

Further dabblings. I'm now using another app called RoboRemo, which enables me to design my own controller. I've also changed the coding so I get a much wider range of speed steps - but these seem to depend on the PWM setting I use. Steve Massikker uses 122.5Hz, which makes the loco growl especially at low speeds. The Arduino default value is 490Hz, which makes it whine. I've now discovered how to vary the PWM setting and so here's how the loco behaves on 12kHz and 8kHz.



I'm playing around with the SD Player which Tom mentioned and Greg has been playing around with. I'll post where I'm up to when I get it to behave itself..... :?

Rik
------------------------
Peckforton Light Railway - Blog Facebook Youtube

User avatar
philipy
Moderator
Moderator
Posts: 5033
Joined: Sun Jan 30, 2011 3:00 pm
Location: South Northants

Re: Initial experiments with Bluetooth and Arduino

Post by philipy » Mon Jul 08, 2019 1:16 pm

Certainly looks nice, smooth control Rik.
Not sure about the noise, tbh. I suspect that my sound set up may be distorting things, I didn't really get a whine, but I did hear what sounded not unlike a London Underground train, at one point!
Philip

User avatar
GTB
Driver
Driver
Posts: 1550
Joined: Sat Mar 05, 2011 2:46 pm
Location: Australia

Re: Initial experiments with Bluetooth and Arduino

Post by GTB » Mon Jul 08, 2019 2:27 pm

ge_rik wrote: Mon Jul 08, 2019 10:34 am I've now discovered how to vary the PWM setting and so here's how the loco behaves on 12kHz and 8kHz.
Most human hearing goes up to about 20kz, although sensitivity at the higher frequencies drops off as you get older. From memory 'silent drive' DCC decoders run above 15kHz.

I can hear the buzz from the PWM at both 8 and 12kHz in your video (that or it's gear noise). I read somewhere that an Arduino board can get into the supersonic PWM frequency range, but you'd need to check the H-bridge driving the motor can handle those frequencies as well.

Regards,
Graeme

User avatar
ge_rik
Administrator
Administrator
Posts: 6497
Joined: Sun Oct 25, 2009 10:20 pm
Location: Cheshire
Contact:

Re: Initial experiments with Bluetooth and Arduino

Post by ge_rik » Tue Jul 09, 2019 8:55 am

GTB wrote: Mon Jul 08, 2019 2:27 pm
ge_rik wrote: Mon Jul 08, 2019 10:34 am I've now discovered how to vary the PWM setting and so here's how the loco behaves on 12kHz and 8kHz.
Most human hearing goes up to about 20kz, although sensitivity at the higher frequencies drops off as you get older. From memory 'silent drive' DCC decoders run above 15kHz.

I can hear the buzz from the PWM at both 8 and 12kHz in your video (that or it's gear noise). I read somewhere that an Arduino board can get into the supersonic PWM frequency range, but you'd need to check the H-bridge driving the motor can handle those frequencies as well.

Regards,
Graeme
Hi Graeme
Yes, still get buzz at low speeds on both settings. I might try increasing the frequency to see if it disappears. One thing I have found is that increasing the frequency seems to diminish the range of speed settings to which the motor responds. I get a range of 0 - 255 from the slider on the app and at lower frequencies (eg 490Hz) I can use the full range - though the motor doesn't start until about 40. When I set the frequency to 8kHz, the usable range of steps drops to 70 - 130. At 12kHz, the range drops further from 80 to 120. Not entirely sure why.

Rik
------------------------
Peckforton Light Railway - Blog Facebook Youtube

User avatar
tom_tom_go
Driver
Driver
Posts: 4824
Joined: Wed Feb 23, 2011 3:08 am
Location: Kent, UK
Contact:

Re: Initial experiments with Bluetooth and Arduino

Post by tom_tom_go » Tue Jul 09, 2019 9:07 am

Would using capacitors on the motor help reduce noise?

User avatar
GTB
Driver
Driver
Posts: 1550
Joined: Sat Mar 05, 2011 2:46 pm
Location: Australia

Re: Initial experiments with Bluetooth and Arduino

Post by GTB » Tue Jul 09, 2019 10:40 am

ge_rik wrote: Tue Jul 09, 2019 8:55 am One thing I have found is that increasing the frequency seems to diminish the range of speed settings to which the motor responds.
The higher the pwm frequency, the more like DC it becomes, so the motor starting voltage increases. That may be what you are seeing.

When DCC went to 'silent' decoders, they had to add some form of kickstart to improve slow running. Or they changed to back emf control, which is effectively a cruise control.

Regards,
Graeme

User avatar
ge_rik
Administrator
Administrator
Posts: 6497
Joined: Sun Oct 25, 2009 10:20 pm
Location: Cheshire
Contact:

Re: Initial experiments with Bluetooth and Arduino

Post by ge_rik » Tue Jul 09, 2019 1:49 pm

Latest developments. I've now incorporated sound from a small SD Player module. The tracks are played either in response to key presses on the app (ie the horn and the engine start / stop) and the speed setting determines which of three tracks play (idle, slow speed, fast speed). Not yet perfect. The sound files need a bit of tinkering, but the principle seems to work OK.

Had to revert to the default PWM setting of 490Hz as the PWM library in the Arduino compiler developed a fault.

Getting there ... albeit slowly!



Rik
------------------------
Peckforton Light Railway - Blog Facebook Youtube

User avatar
FWLR
Driver
Driver
Posts: 4262
Joined: Sat Aug 05, 2017 9:45 am
Location: Preston, Lancashire, UK

Re: Initial experiments with Bluetooth and Arduino

Post by FWLR » Thu Jul 11, 2019 9:09 am

Well I think it's great Rik. :thumbright: :thumbright: The engine idle and running is far better than some. The horn maybe needs tweaking a bit and the start timing may just need altering, but a man of your skills will no doubt overcome such things.

This is the same comment I have put on your Youtube channel. It's not because I can't be bothered to write anything. It's, I can't think of anything else to say about how fabulous it sounds, oh I just have.... :lol: :lol:

User avatar
ge_rik
Administrator
Administrator
Posts: 6497
Joined: Sun Oct 25, 2009 10:20 pm
Location: Cheshire
Contact:

Re: Initial experiments with Bluetooth and Arduino

Post by ge_rik » Sat Jul 13, 2019 12:32 pm

I think I've improved the sound files - though maybe you should be the judge.

.
I've blogged what I've done here just in case anyone ever wants to have a try themselves:
https://riksrailway.blogspot.com/2019/0 ... art-4.html
.
I think I've more or less finished my experimentations with Bluetooth and phone apps. It might be because I am not an avid user of a mobile phone, but I do find using a phone to be a nuisance compared with a handheld transmitter. Not only is it hard to see the screen but I find it all too easy to press one of the buttons on the side of the phone and switch the darn thing off - usually at a critical moment. I'm sure it would be possible to pair more than one loco with the app and switch from controlling one to the other, but my Deltang Tx22 does that quite easily, so I can't see it is much of an advantage. I suppose the real advantage is that it's possible to equip a loco with Bluetooth control and sound for just under £20 (plus the cost of the batteries - another £5) - even cheaper if you get your gear directly from China.

Anyway - my dabblings (ie circuitry and programming codes) are there for anyone to play around with if you're more tech-savvy than me.

Rik
------------------------
Peckforton Light Railway - Blog Facebook Youtube

User avatar
FWLR
Driver
Driver
Posts: 4262
Joined: Sat Aug 05, 2017 9:45 am
Location: Preston, Lancashire, UK

Re: Initial experiments with Bluetooth and Arduino

Post by FWLR » Sat Jul 13, 2019 1:10 pm

Thats superb Rik. A vast improvement on your last version. The start up and moving off is fantastic and the horn even sounds better as well. Thanks for giving us an in-site into Bluetooth control. If somebody with your talents think it's better with traditional remote control, who am I to disagree.... :roll: :roll:

But if you what to move the loco or even the electronics with the SD Card, I will gladly take it off your hands........ :lol: :lol: :lol: :lol:

User avatar
tom_tom_go
Driver
Driver
Posts: 4824
Joined: Wed Feb 23, 2011 3:08 am
Location: Kent, UK
Contact:

Re: Initial experiments with Bluetooth and Arduino

Post by tom_tom_go » Sat Jul 13, 2019 6:11 pm

I believe you should be right chuffed with what you have achieved Rik given you were born in a generation where computers and coding were not mainstream.

Bluetooth (or Wi-Fi, I don't see the benefit or using Bluetooth over Wi-Fi) for controlling indoor layout operation with an app would appeal to me, however, outside in the outdoors l prefer to keep loco running as low tech as possible.

User avatar
ge_rik
Administrator
Administrator
Posts: 6497
Joined: Sun Oct 25, 2009 10:20 pm
Location: Cheshire
Contact:

Re: Initial experiments with Bluetooth and Arduino

Post by ge_rik » Sat Jul 13, 2019 6:38 pm

FWLR wrote: Sat Jul 13, 2019 1:10 pm But if you what to move the loco or even the electronics with the SD Card, I will gladly take it off your hands........ :lol: :lol: :lol: :lol:
Thanks Rod. Although it looks very toylike, it's actually quite useful as a test-bed loco. The three components of the body just clip together, so it's dead easy to take apart to tinker and then put together again.

I'm planning on experimenting with more traditional RC with the Arduino next - so I can make a Tx with a knob, push buttons and a reversing switch - back to more familiar territory.

Rik
------------------------
Peckforton Light Railway - Blog Facebook Youtube

User avatar
ge_rik
Administrator
Administrator
Posts: 6497
Joined: Sun Oct 25, 2009 10:20 pm
Location: Cheshire
Contact:

Re: Initial experiments with Bluetooth and Arduino

Post by ge_rik » Sat Jul 13, 2019 6:43 pm

tom_tom_go wrote: Sat Jul 13, 2019 6:11 pm I believe you should be right chuffed with what you have achieved Rik given you were born in a generation where computers and coding were not mainstream.
Thanks Tom .... not quite over the hill (yet) ..... ;)
I've always tinkered with programming, ever since I got my first Commodore Vic 20 and then moved on to a Sinclair Spectrum and eventually on the the heady heights of a BBC B Micro. But I'm very much a self-taught dabbler with coding. I learn only as much as I need to know. I suppose I skate about on top of the iceberg knowing there's a girt big block of something or other beneath me, but enjoying the view from the top.

Not sure if the metaphor quite works, but hopefully you get my drift. :? :lol:

Rik
------------------------
Peckforton Light Railway - Blog Facebook Youtube

User avatar
-steves-
Administrator
Administrator
Posts: 2412
Joined: Thu Jul 28, 2011 1:50 pm
Location: Cambridge & Peterborough

Re: Initial experiments with Bluetooth and Arduino

Post by -steves- » Sat Jul 13, 2019 6:44 pm

Looks and sounds great Rik, a grand job. Think I still prefer TX22 / TX24 for ease of use for me, but for someone it will be a hoot :thumbup:
The buck stops here .......

Ditton Meadow Light Railway (DMLR)
Member of Peterborough and District Association
http://peterborough.16mm.org.uk/

User avatar
tom_tom_go
Driver
Driver
Posts: 4824
Joined: Wed Feb 23, 2011 3:08 am
Location: Kent, UK
Contact:

Re: Initial experiments with Bluetooth and Arduino

Post by tom_tom_go » Sat Jul 13, 2019 6:46 pm

The first computer I used in school was BBC Micro!

https://en.m.wikipedia.org/wiki/BBC_Micro

User avatar
FWLR
Driver
Driver
Posts: 4262
Joined: Sat Aug 05, 2017 9:45 am
Location: Preston, Lancashire, UK

Re: Initial experiments with Bluetooth and Arduino

Post by FWLR » Sun Jul 14, 2019 8:53 am

ge_rik wrote: Sat Jul 13, 2019 6:38 pm
FWLR wrote: Sat Jul 13, 2019 1:10 pm But if you what to move the loco or even the electronics with the SD Card, I will gladly take it off your hands........ :lol: :lol: :lol: :lol:
Thanks Rod. Although it looks very toylike, it's actually quite useful as a test-bed loco. The three components of the body just clip together, so it's dead easy to take apart to tinker and then put together again.

I'm planning on experimenting with more traditional RC with the Arduino next - so I can make a Tx with a knob, push buttons and a reversing switch - back to more familiar territory.

Rik
And I am sure it will be a success Rik.... :thumbright: :thumbright:

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests