Any Arduino Gyro Projects

Any old or new electronic projects on the go
Post Reply
bluejets
Posts: 317
Joined: 19 Jun 2019, 04:09

Re: Any Arduino Gyro Projects

Post by bluejets »

Wow...impressive what you can do in 24 hours or so.

Did notice notes that there are a few bits from a previous project but still ......great stuff.

Most over my head but I'll read through it all a few more times, maybe some things will spark the brain cells.

Will be interested to see how you change to suit the ATtiny85.
Do you use P1 for dual purpose..?
I think the ATTiny85 will be the final choice for me and I think for Pchristy as well.
If all goes well I'll knock up a pcb layout.

Just put my Mum and Dad in care for a couple of weeks so the running around will mean limited or late night approach to trying your system.

Have a couple of GY-521 modules which have the MPU6050 chip which I think should be ok.

Cheers Jorgo
Attachments
MPU6050.jpg
GY521.jpg
Pchristy
Posts: 417
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy »

Excellent work! I'm very impressed!

Looking forward to seeing the ATtiny85 version! :)

--
Pete
User avatar
Phil_G
Posts: 603
Joined: 15 Feb 2018, 23:32
Contact:

Re: Any Arduino Gyro Projects

Post by Phil_G »

This was my first 'MicroBit' thing a while back:




The Python code is minimal, two lines do all the work:

# Camera gimbal in Python for BBC Micro:bit
from microbit import *
pin0.set_analog_period(20)
while True:
newpos=accelerometer.get_x()/41+75
pin0.write_analog(newpos)
Martin
Posts: 745
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin »

Neat, but it probably didn't work as expected (if at all) on an actual motorbike, because the accelerometer would (like the motorcycle itself) lean into the turns, detecting its local 'down' direction as a combination of gravity and centrifugal force.

You could use it in a car though (that corners flat) to make the camera lean into the turns - as if it were on a motorbike!

I think to keep the camera level, you'd need an actual gyro rather than an accelerometer - though an accelerometer would be also be useful to correct for any long term gyro drift,
Martin
Posts: 745
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin »

I've done an ATtiny85 version - works just the same, except that there isn't a spare pin to work the LED. Well there would be if we did the fuse-changing trick to change the RST pin into an extra I/O pin - but I think that's more trouble than it's worth. The Digispark board I'm using has an on-board LED on D1, but I'm using that pin as the 'AUX' channel input, that selects operating mode and gain, or for serial output when debugging.

Jorgo, yes that's the same module I'm using: GY-521. Sorry, I don't understand what you meant by your 'P1 for dual purpose' question - can you elaborate?

The comments in the config.h file explain how to connect it up. Unlike the 328P version, there are no options on which pins are used. (Edit: removed comments about external pull-ups - no longer needed now I've slowed the I2C communications down to a sensible rate).

Now I suppose I have to solder a couple of them up and 3D-print some cases. Peter, Jorgo, are you volunteering to flight test (or road test or lake test) them? It will save me the bother! PM me mailing addresses if you're prepared to do it.

The same version of the sketch now compiles for both the ATMega328P (Uno, Nano, etc), and the ATtiny85. I've not attached it here, but instead updated the sketch attached to my post at the bottom of page 2.
Last edited by Martin on 11 Jul 2020, 11:39, edited 5 times in total.
bluejets
Posts: 317
Joined: 19 Jun 2019, 04:09

Re: Any Arduino Gyro Projects

Post by bluejets »

Martin wrote: 04 Jul 2020, 21:24 Sorry, I don't understand what you meant by your 'P1 for dual purpose' question - can you elaborate?
Hi Martin,
I took a quick look at how you might approach the changeover to the ATtiny85 and it became immediately obvious that there would be a pin shortage as compared to the Arduino if all aspects were covered.
As I said, not any where near as qualified as yourself in these applications so I just imagined you might have in mind to use P1(D1) both as an LED output for the original purpose and then somehow switch it to servo out later in the program.

Would do some flight testing however, with my Mum and Dad situation at present, time is short.
That plus the eye specialist bloke I build UV units for is opening a new office and needs another unit so busy busy for me at the moment.

Having said that, I'll fit in what I can.

You must be well organised and experienced to pump out these creations in such a short period of time.
Hat off to you...great job.

Cheers Jorgo.

Edit:.... noticed this in your program....
*****************************************************************************
// ******** IMPORTANT! pull up resistors MUST be fitted to SCL and SDA ********
// ******** you might get away without using them on a 328P, but you ********
// ******** probably won't with an ATtiny85. You have been warned! ********
// *****************************************************************************

The GY521 board I have here already have 2K2 pullups to the 3v3, so are you saying they require additional pull up resistors ?

https://protosupplies.com/product/mpu-6 ... or-module/

Assume your pin numbers in the comments (3,4 and 1) are same as D0 to D4 below.??
Attachments
Digispark-Pinout.jpg
Digispark-Pinout.jpg (19.95 KiB) Viewed 2134 times
MPU-6050-GY-521-Accelerometer-Schematic.jpg
Martin
Posts: 745
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin »

bluejets wrote: 05 Jul 2020, 00:33 I took a quick look at how you might approach the changeover to the ATtiny85 and it became immediately obvious that there would be a pin shortage as compared to the Arduino if all aspects were covered. I just imagined you might have in mind to use P1(D1) both as an LED output for the original purpose and then somehow switch it to servo out later in the program.
I did consider using the built-in LED pin for both LED duties and driving the servo output, but I thought it might upset some servos causing them to go to full travel. I also thought about using the LED on either the rudder or Aux inputs from the receiver. I don't think that would damage any receivers, but in the very unlikely worst case, depending on which receiver channels had been used, it might just switch some receivers into bind mode. The LED probably won't be all that visible, once the Digispark is inside a case, and the user will know that the gyro is calibrating anyway, because the servo won't move until the calibration is complete, so I decided not to bother with the LED.
Would do some flight testing however, with my Mum and Dad situation at present, time is short.
That plus the eye specialist bloke I build UV units for is opening a new office and needs another unit so busy busy for me at the moment.

Having said that, I'll fit in what I can.
Hope your Mum and Dad situation improves soon, and good luck with your work!
The GY521 board I have here already have 2K2 pullups to the 3v3, so are you saying they require additional pull up resistors ?
That's interesting. I did find I needed additional pull ups on my breadboard rig for reliable operation. However, I did have the USBASP connected to the SDA and SCL lines, as well as the gyro, and I was also using the USBASP to power everything ( including the servo :? ) so I'll do some more tests later with the programmer unplugged and a better power supply. Maybe the external pull ups won't be needed then.
Assume your pin numbers in the comments (3,4 and 1) are same as D0 to D4 below.??
Yes, sorry, I tend to be a bit careless about 'pin numbers'. I was using them to mean the usual Digispark and Arduino 'D numbers' - not the physical pin numbers on the I.C.

I now realize that, because SoftwareSerial conflicts with pinchange interrupts, so that the AUX input can't be used when in DEBUG mode, it would be more sensible to move the SoftwareSerial debug output to the AUX pin instead of the servo pin, so I'll do that. Also, I'll make the debug output more comprehensive.

I also thought that once the gubbins are inside a case, the case will be not-quite-a-cube, plus the wires have to exit somewhere, so I'll add a configuration option to select any of the gyro's three axes to be used as the control axis - that will allow the gyro to be mounted any way up by editing the configuration. I'll probably separate out the configuration options into their own file too.

Because the user might want to edit the configuration, and possibly also upload future improved versions of the program, we need to have all the 'programming wires' outside the case. Of course, three of the six necessary wires are available anyway, because one of them doubles up as an input from the receiver (I'll probably make that the 'AUX' input), and there are the two power lines.

I'm thinking of having short leads with plugs that, for normal operation, will plug into receiver channels (or servo extension leads to receiver channels) for the two 'inputs' and a short lead with a servo socket for plugging in the servo (again with an extension lead if necessary).

The remaining 'programming wires' (RST, MOSI, MISO) will run to their own connector. For configuring or programming the gyro, the user will need a USBASP with a custom harness to connect to the 'programming connector' and (probably) the AUX receiver plug.

I'm intending to wire the positives from the receiver and the positive out to the servo to the Digispark's VIN pin. That means the user can run the unit at any normal model voltage: 4.8, 5, 6, 7.2, etc. When running at 4.8V the Digispark and the power out to the Gyro board will only be running at about 4V, because of the volt drop across the Digispark's regulator. But it seems to run perfectly reliably at that. I'll test the actual drop-out voltage later.
Pchristy
Posts: 417
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy »

Martin,

Thanks for your kind offer of an "evaluation" gyro! I've sent a PM, and have the ideal model lined up as a test bed!

:)

--
Pete
Martin
Posts: 745
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin »

Excellent! :D

I've been building them up today and will most likely have them in 3D-printed cases and finished testing by Wednesday. I'll post a little video showing the completed gyro before putting it in the post.
Martin
Posts: 745
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin »

Took me a little longer than expected to post the video - I went flying a few times early in the week, and then I've been having problems with camera batteries and memory cards when shooting the video.

But I've posted it now. It's a bit long and rambling - mostly covering how to set up the Arduino IDE and USBasp to suit the ATtiny version - but it does show the finished (?) gyro in operation. You can just fast-forward through the boring bits - I can't be bothered to shoot it again!

Post Reply