NXT UAV

Discussion specific to projects ideas and support.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXT UAV

Post by mattallen37 »

To read the length of a servo pulse from the receiver, you would need to use external processor interrupts. I don't know if the PICAXE supports that, so you might need to use Arduino instead.

You could build a circuit that toggles the control pins of the servos between the servo controller and the receiver. I am thinking of something like the 4053 IC. There would probably be a slight glitch in the servo position during transition, but only for a very short time.

Edit: BEC?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
pepijndevos
Posts: 175
Joined: 28 Dec 2011, 13:07
Location: Gelderland, Netherlands
Contact:

Re: NXT UAV

Post by pepijndevos »

4053 IC? Google says it's an analog multiplexer, no idea what that means.

I have toggle switches on my transmitter, but it's still a PWM signal I think. So wouldn't that still have the same problem?

If you are talking about toggling from the NXT side, that would only be useful when the NXT or the sensor can detect an error. That wouldn't help when flying into a tree.

BEC: Battery Elimination Circuit

Speed regulators commonly supply 5V over the servo pins so that you can power the receiver with the main battery, instead of a separate 4.8v battery.

So, to build your controller, what do I need? From what I gather:
  • PICAXE-20M2 Starter Pack(couldn't find a X one)
  • PICAXE-20X2 Microcontroller
  • 20 pin IC Holder
  • female NXT plug
  • header pins
  • some 330ohm resistors
  • a 10k resistor
  • a 22k resistor
  • solder-less breadboard
In case you didn't notice: I can fly planes, write code, hold a soldering iron, but I have no clue about anything that has a bug-like form factor(IC).
-- Pepijn
http://studl.es Mindstorms Building Instructions
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXT UAV

Post by mattallen37 »

A BEC motor controller should be fine. Just make sure you have a common ground.

Indeed, the 4053 is an analog multiplexer, but it should work fine with digital signals as well (PWM servo signals). Digital is just analog to the extremes (really high, or really low).

The idea of using a 4053, is that you could switch between manual and auto control mode (you would switch which controller the servos are connected to). A 4053 is basically an electric 3PDT switch.

The servo controller I made and gave you a link to, is for controlling servos, much like the NXTServo from mindsensors. If you already have their controller, it would be pointless to make your own.

If you want to make the controller on a solder-less breadboard, you need:

PICAXE 20X2
Breadboard connection to NXT sensor port. I suggest you use an NXT female socket breakout
Breadboard connection to a computer RS232 port (only Gnd, RX and TX)
10k resistor
22k resistor
330 ohm resistors (one for each servo output, so 6 if you use all outputs)
header pins (3 per servo)
solder-less breadboard
hookup wire
5-6v power supply (or BEC)

No need for a starter pack. You also don't need an IC socket if you are using a solder-less breadboard.

If you want me to, I can draw a block diagram of what I envision.

Edit:
NXT UAV manual over-ride block diagram.zip
(38.31 KiB) Downloaded 323 times
Edit 2: I didn't show how to control the 4053 (switch it), but it just requires a high vs. low logic signal.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
pepijndevos
Posts: 175
Joined: 28 Dec 2011, 13:07
Location: Gelderland, Netherlands
Contact:

Re: NXT UAV

Post by pepijndevos »

Ok, I think I almost get what the 4053 does.Two questions 1) would I need one for every servo? 2) Can you drive the switch with a PWM signal, or does it switch on lo/hi input?

If a block diagram isn't to much work, that would be really great.

Glad I don't need the starter pack, it's like 70% of the total costs :) I do need to get at least some sort of cable to program it, right? Maybe I can just strip a regular USB cable...

BTW, it does seem that the 20X2 has interrupts: http://www.picaxeforum.co.uk/showthread ... INT1-INT2) I think I have some reading to do…

edit: Ok, logic signal. Then I still don't get it. Who is going to flick the switch, up there in my plane? The reason for the override, is to take control when something goes wrong, so I would need to flick that switch from the ground.
-- Pepijn
http://studl.es Mindstorms Building Instructions
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXT UAV

Post by mattallen37 »

You would need a 4053 for every 3 servo channels (3PDT).

To "switch" it, it needs to be a logic hi/low, not PWM. If all you have available is a PWM signal, you could probably use a uC to determine the length of the pulse, and set the logic IO accordingly.

You do need a cable, yes. USB will not work; you need RS232. If your computer doesn't have an RS232 port, you can get a USB > RS232 adapter.

I suggest you look at the cable options SFE has to offer:
Official PICAXE USB programming cable, if you want the official USB cable.
RS232 cable, if you have an RS232 port, or a USB > RS232 adapter (with DB9 connection).
SFE PICAXE USB programming adapter, if you want the cheaper of the USB options. You will also need a USB mini cable, and a 3.5mm - 3.5mm stereo cable.

For the serial to breadboard connection, I suggest using an audio jack and the matching breadboard breakout.

If you don't have an RS232 port, the cheapest programming option would be to get an inexpensive (though decent) USB > RS232 adapter from someplace like ebay, and then hack an old RS232 cable for connection to the breadboard.

Thanks for the link to the topic about PICAXE interrupts, I will definitely read that again.

Since I made that PICAXE based servo controller, I have started using Arduino a lot. I haven't used it with servos yet, but I have used it as an NXT I2C slave device. I think Arduino might be the way to go. It's fairly in-expensive (you can buy a mock nano on eBay for $15, and the nano has USB > serial on-board), and it is really easy to use. Using the Arduino, you could read the length of a PWM pulse, so you know the state of the toggle switch.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
pepijndevos
Posts: 175
Joined: 28 Dec 2011, 13:07
Location: Gelderland, Netherlands
Contact:

Re: NXT UAV

Post by pepijndevos »

That is why I listed the starter pack, it includes all the cables and converters I need.

Ok, so you suggest I use an Arduino instead of a PICAXE? This one? http://arduino.cc/en/Main/ArduinoBoardNano

What does the Arduino have that the PICAXE doesn't, that make it more useful in this case? That board also has 2 interrupts.

So with 2 interrupts, on either the Arduino or PICAXE, can I read 2 PWM signals?

Some googling seems to indicate that both the Arduino and the PICAXE have a pulsein command: http://www.ozelecforum.com/viewtopic.php?f=5&t=257 Not sure if that uses the interrupt or not, but it looks promising.
-- Pepijn
http://studl.es Mindstorms Building Instructions
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXT UAV

Post by mattallen37 »

The Arduino seems to have more community support than PICAXE, and it is a lot easier to program. You have to use BASIC for the PICAXE, and IMO it stinks. I much prefer C/C++ (which is used for Arduino). The Arduino has many, many resources not available on the PICAXE.

I started out with PICAXE, so I have done more projects with it than with Arduino. That also means that I have tested it to be true in many more situations. However, I am now using Arduino for lots of stuff, and am realizing that it is slightly more complex to interface to the NXT, but the benefits far out-weigh the disadvantages in most situations.

Yes, that is the Arduino I was talking about. Almost all Arduinos have the same functionality, it's just a matter of how many accessories they have (such as USB on board...).

The Arduino has 6 PWM outputs, vs. 1-4 on the 20X2.
The Arduino has 3 timers; 2 8-bit, and 1 16-bit, that can be prescaled from the main clock, independently of each-other. There is support for timer over-flow interrupts, as well as set-time interrupts. One of the 8-bit timers is used to increment millis and micros (32-bit unsigned "CurrentTick" counters).
The external interrupts I have tested to work with NXT motor encoders. I have not tested them to be able to read the length of a PWM pulse, but I will try to write a program to do just that (I can see many possibilities now, for something like that). It should be fairly simple to do.
I could go on and on... Basically, the 20X2 is good at doing one simple task that isn't time-reliant, and the Arduino is good at almost everything else that isn't overly complex.

Just as an example of the power of Arduino, a little while ago I made an NXT > PF controller with an Arduino (like the HT IR Link, or mindsensors PF Mate). I set the Arduino up to be an I2C slave, and used timer 1 to cause interrupts for sending the PF IR protocol messages (totally bit-banged), and it seems to work perfectly! This included simple (3 "task") multitasking, which is AFAIK impossible on the 20X2.

Since the Arduino Nano is self contained (USB on board and such) and fairly small, it seems like a good option for someone (like you) who wants a uC prototyping platform. And for $15 for a mock Nano on eBay, that's the price of an FTDI for programming the PICAXE with USB.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXT UAV

Post by mattallen37 »

I wrote a simple Arduino program to determine the length of a pulse, and it works really well. It's precision is 4uS.

You shouldn't have any trouble determining the length of the PWM servo pulses using the external interrupts of the Arduino.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
pepijndevos
Posts: 175
Joined: 28 Dec 2011, 13:07
Location: Gelderland, Netherlands
Contact:

Re: NXT UAV

Post by pepijndevos »

Cool, I'll probably get one of those. Is the circuit similar to the PICAXE version? I'll look through your Arduino stuff, to see if I can figure out what to do :)

Still, the PICAXE attracts me in a strange way...
-- Pepijn
http://studl.es Mindstorms Building Instructions
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXT UAV

Post by mattallen37 »

PICAXE is just a PIC IC with a special bootloader. Arduino is an AVR with a special bootloader as well, but Arduinos are actually PCBs with parts on them; like a resonator or crystal, LEDs, voltage regulators, sometimes USB > Serial converter.

PICAXE is great for simple, and small applications. I still use it almost as much as Arduino.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest