I want to connect a APM to an Arduino and send information from the Arduino to the APM.
I just want to send 1 signal to the APM when a condition is met.
If you could make it as simple as possible, i know enough programming.
I want to connect a APM to an Arduino and send information from the Arduino to the APM.
I just want to send 1 signal to the APM when a condition is met.
If you could make it as simple as possible, i know enough programming.
You need to be a member of diydrones to add comments!
Replies
i am trying to achieve something similar to driver my rover using RC Inputs to control DC motors.
I wanted to ask if i can make the APM work without a radio controller.
I want the APM to go into a grid search( I will make the search commands by myself), then when it receives the signal from the Arduino it loiters.
SO can the APM fly without a radio controller and still follow what i want?
I am fine with using a port/channel but not a controller
Then there is the failsafe based on throttle values. You would have to turn off the throttle failsafe.
If anything goes wrong you also have no way of recovering without RC control.
If you don't have much experience with arducopter, I'd strongly suggest installing SITL and using mission planner to play with its features before trying anything in the team world.
Which of the two do u think is better for me to use, I opened SITL setup window and understood how it works, and i already know what is mission planner, but still cant decide.
Thank you for all your help, you seriously helped me with everything.
SITL is a simulator for the arducopter software. It also has a basic ground control tool with mavproxy. It's not very user friendly so I prefer to control the SITL simulator with Mission Planner, Tower or another GCS.
Start Mission planner and note the IP address of the machine it is running on. Set it to UDP using the drop down list on the top right of it's screen.
Then start up the simulator using
> sim_vehicle.sh --out 191.168.1.10:14550
(or whatever the mission planner IP address is).
From there you can control the SITL simulator using mission planner as if you were connected to a real aircraft. You can test out all the functionality.
To raise the throttle for takeoff, you will still need to use the SITL command line given there is no RC controller. Type
> rc 3 1600
to raise the throttle, then you can return to Mission planner, arm/disarm, switch modes etc.
There are a number of ways this can be done.
If you want to control something on the APM, you might need to use mavlink, in which case you need to connect your arduino to one of the APM serial ports. It takes a little bit of work to get Mavlink send/recv working on Arduino, but gives you rich control over the APM.
If you want to do something simple, you could just send a PWM value to one of the RC channels on the APM. You can set the higher channels (> 4) to do various things via mission planner. Generating PWM values on Arduino is simple using one of the PWM libraries.
It really depends what you want to do. You'll need to provide more info so people can help
To change mode, you can either send a PWM value on CH5, or use Mavlink. Given Ch5 is probably occupied by your Radio Rx, you will have to use the more complex Mavlink way.
Basically, you need to generate a mavlink_msg_set_mode packet and send down the serial port from your arduino to the APM. If you grab the mavlink messages from here https://github.com/diydrones/ardupilot/tree/master/libraries/GCS_MA...
Then build and send a mode changes like this
mavlink_message_t msg;
uint8_t mMsgBuffer[255];
uint16_t len = mavlink_msg_set_mode_pack(255, 190, &msg , 1 , 1 , (uint32_t)mode );
mavlink_msg_to_send_buffer(mMsgBuffer, &msg);
Serial.write(mMsgBuffer, len);
mode is a number corresponding to the mode you want. loiter is mode 5 for copters.
Make sure you test this very well on the ground before trying to fly with it, changing to the wrong mode could result in bad things happening!
In that case you just need to generate the right PWM value to switch modes. Set up your APM modes as per the instructions when using an RC Tx. If you want loiter, then make that one of the modes and note the PWM range needed for that mode. You can do all this in mission planner.
Then on your Arduino, I'd use something like the Servo library, which has a writeMicroseconds function.
Find a pin on your Arduino that can do PWM (each board is different, check the pinout diagram for yours). Then use the attach() function of the servo library to connect to that pin.
Connect a wire between that pin to the signal pin on CH5 IN on the APM. You will also need to connect the grounds (I assume you are powering this all from one battery?)
You will now have control over the APM. You also need to think about the default value coming from your Arduino as it will control what mode the copter is in before your trigger loiter.