Author Topic: Pi newbie with microcontroller question...  (Read 1450 times)

0 Members and 1 Guest are viewing this topic.

Offline YanelTopic starter

  • Newbie
  • Posts: 1
  • Country: us
Pi newbie with microcontroller question...
« on: November 10, 2020, 09:48:01 pm »
Hi guys!

I'm a student at the University of Montana studying physics. I'm currently working for a department doing atmospheric research. One of my projects involves putting a sensor package on a drone. In the long term, we'd like to be able to control the drone and receive data from the sensor package from a ground station running LabVIEW. With all this having been said, I'm fairly new to the world of Pi's and microcontrollers and I'm running into a few roadblocks. In my head, I have this image of running a Pi and Arduino up in the payload, with the Arduino controlling the rotors on the drone (with the Pi able to write new commands to the Arduino) and have sensor data coming in to the Pi. Send and receive would be controlled by an XBee Series 2 2.4 GHz RX.

The big hurdle I'm coming to is that I can't seem to figure out how to make my Pi (It's the Pi 2, I should mention. Just running Raspbian out of the box.) communicate with my Arduino. Like, at all. So, would you guys have any resources/suggestions on where to get started on a project like this? It's needed for my new project about casinos - for this page about Jackpot City casino mobile (https://mobilecasino-ca.com/jackpot-city-casino.html). Can you advise me something?

Thanks!
« Last Edit: November 30, 2020, 07:00:27 am by Yanel »
 

Offline Joku

  • Contributor
  • Posts: 11
  • Country: au
Re: Pi newbie with microcontroller question...
« Reply #1 on: November 11, 2020, 01:14:10 am »
There should be plenty of guides for this on the internet.

You probably want a uart connection between the RPi and Arduino so google things like "RPi Arduino uart".

You will need to consider potential ~3V / 5V level conversion issues, what you find via googling should help with that.

I would recommend starting by breaking down the uart comms functionality into two separate basic verification steps. Connect one of the two devices (RPi or Arduino) individually to a PC first using a uart<->usb converter into a PC USB port, using a PC comms terminal app to verify that you have TX/RX working (you can do that one at a time too, I usually do the embedded devices TX first, ie. Check I get successful RX on the PC side first). Once you're happy you have one of those working, repeat for the other device (RPi or Arduino). Once both are verified, you can move onto connecting them together.

When connected together, you can choose to "sniff" the comms by tapping either one of the uart comms lines with the RX pin (only!) of the uart<->usb converter, if you want to sniff both uart lines from the PC you will need a second uart<->usb converter so you can have 2x RX lines. Whether this is much use to you really depends what you're doing. While developing your Arduino<->XBee code, that's probably going to be uart too, and you may want to do the same kind of sniffing of that uart connection for a while too.
« Last Edit: November 11, 2020, 01:17:18 am by Joku »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Pi newbie with microcontroller question...
« Reply #2 on: November 11, 2020, 01:17:08 am »
Most Arduinos already have a USB port connected to the UART, simply plug that into a USB port on the Pi.
 

Offline Joku

  • Contributor
  • Posts: 11
  • Country: au
Re: Pi newbie with microcontroller question...
« Reply #3 on: November 11, 2020, 01:24:09 am »
Most Arduinos already have a USB port connected to the UART, simply plug that into a USB port on the Pi.

Possibly a horribly wasteful use of the USB ports on either or both sides though, and less robust, all depends on the application I guess. Also, I'm not an Arduino user so I'm pretty ignorant on this matter but I thought Arduino users would generally want to keep the USB port available for programming so using it as an application port is also a bit of a dev nuisance?
« Last Edit: November 11, 2020, 01:30:35 am by Joku »
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4421
  • Country: nz
Re: Pi newbie with microcontroller question...
« Reply #4 on: November 11, 2020, 01:39:14 am »
Most Arduinos already have a USB port connected to the UART, simply plug that into a USB port on the Pi.

Possibly a horribly wasteful use of the USB ports on either or both sides though, and less robust, all depends on the application I guess. Also, I'm not an Arduino user so I'm pretty ignorant on this matter but I thought Arduino users would generally want to keep the USB port available for programming so using it as an application port is also a bit of a dev nuisance?

You can program the Arduino using avrdude running *on* the Pi. And avr-gcc also, for that matter.

A standard Pi 2 and Arduino Uno board would start to add up quite a bit in weight. You can certainly find much smaller compatible boards. Whether that matters depends on the size of the drone, of course. You could use a Pi Compute Module and an Arduino Pro Mini -- or a Teensy 4.0, which is vastly higher performance, rivaling a Pi 2 in CPU power.

Also, why not SPI rather than UART?
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9930
  • Country: us
Re: Pi newbie with microcontroller question...
« Reply #5 on: November 11, 2020, 02:34:35 am »
You can even run the IDE on the Pi and have it program the Arduino.  Using the IDE assumes you have the desktop running.  If not, try startx.  You would only do this when writing code for the Arduino.  I assume your drone would fly with the Pi having just a shell so booting to a shell would be correct.

You are going to need some healthy batteries for the Pi.

https://www.raspberrypi.org/documentation/hardware/raspberrypi/power/README.md

Personally, I would want to see if I could run everything from a Teensy 4.1  It turns out that when you install the Teensyduino toolchain, it actually runs under the Arduino IDE and has library functions that mirror the Arduino library.  It's pretty fast at 600 MHz and has a lot of IO pins.

I don't know if the library contains the full FAT file system and I don't know if you application requires it.

https://www.pjrc.com/store/teensy41.html

 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4421
  • Country: nz
Re: Pi newbie with microcontroller question...
« Reply #6 on: November 11, 2020, 06:04:42 am »
You are going to need some healthy batteries for the Pi.

Contraptions that levitate by beating the air into submission with pure thrust from electric motors driving props do tend to have healthy batteries.
 

Offline MarkR42

  • Regular Contributor
  • *
  • Posts: 139
  • Country: gb
Re: Pi newbie with microcontroller question...
« Reply #7 on: November 13, 2020, 06:53:29 pm »
I think realistically you would be better off using an off-the-shelf drone controller, then trying to interface that into the Pi somehow.

But even doing that is fairly complicated, making a custom drone which flies by remote control is difficult enough. If you need results and have the budget, I'd seriously consider using an entirely off-the-shelf drone, or some kit which contains everything.
 

Online Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3784
  • Country: nl
Re: Pi newbie with microcontroller question...
« Reply #8 on: November 16, 2020, 12:20:07 pm »
Beaglebone is sometimes being used for quad copters:
https://html.duckduckgo.com/html?q=beaglebone+drone+controller

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf