Quadricopter + arduino+mpu6050(gyro+oscillo) +PID - arduino

so I'm trying to creat a quadricopter with an arduino and gyroscope mp6050 and this with PID algorithme (using arduino PID,mpu library) so I make everything work separately but when it comes to use PID I don't know how to do it which one will be the input or setput ... I'm confused on how I can use gyroscope information and brushless information and other information to make my quadri fly ... thank you

It sounds like you need a better understanding of what PID does. Here is a great article about real world implmentation of PID http://eas.uccs.edu/~cwang/ECE4330F12/PID-without-a-PhD.pdf
It follows this code from AVR's website exactly (they make the ATMega32p microcontroller chip on the UNO boards) PDF explanation and Atmel Code in C
A PID controller is a feedback control loop.
The input ("Command" on the diagram) is the desired position, in your case this is what you want the gyroscope to read.
The "Output" is a control signal. It will tell your brushless motors (the "Plant") what to do to achieve the desired position.
The Feedback (input/output) We then use our "Sensors" to read the actual position. In your case this is the gyroscope data
Now the PID controller takes the error = desired position - actual position and uses the error to create the next command. The overall goal is to drive the error down to 0, in other words desired position = actual position The exact details of your PID coefficients are based on your specific setup and usually they must be tuned manually in order to achieve desirable results (see the links provided for more details).
Loooking at the Arduino PID Library Documentation shows that they have easy methods to set KP, KD, KI, input, output THey even have an autotune parameter that can automatically find your PID constants. Hope that helps, Good luck.

Related

Trying to interface with an Aanderaa RCM9

I have an older Aanderaa RCM9 (https://epic.awi.de/id/eprint/45145/1/RCM9.pdf) that is missing its Data Storage Unit and its reader. They don't produce these anymore nor do they service the model. It would be a shame to toss an otherwise nice piece of equipment, so I thought to try and get a serial feed from the terminal or DSU output and log on an Arduino with an SD card. I have tried to connect with a TTL-RS232 converter, and there seems to be a consistent Tx from the instrument, it comes in batches, but reads out in CoolTerm as "............" I've tried different terminal configurations, and connections, but that's the best I get. Here's how it looks inside: https://imgur.com/a/xxCPUlQ
Any thoughts??
I am afraid that the output is the old Aanderaa PDC4 serial format where long pulses (81ms) represents zeros and short (27ms) represents ones in a 10 bit binary word framed in a 4 second window.

How can exp(x) be used in xcos?

I'm trying to simulate Ke^(-θs)/(𝜏*s + 1), but xcos won't let me use exp(s) in my CLR block. Is there any way around that?
Also, how can I create an xcos model, without the value for the variables, and then assign the values through the editor?
Thanks!
Your transfer function represents a time delay θ in series with a first order system, use the following block to approximate the delay part : https://help.scilab.org/docs/6.1.0/en_US/TIME_DELAY.html
Depending on what you mean with "to simulate Ke^(-θs)/(𝜏*s + 1)", you may try or use
https://help.scilab.org/docs/6.1.0/en_US/scifunc_block_m.html
or
https://help.scilab.org/docs/6.1.0/en_US/EXPRESSION.html
The second part of your question is quite unclear as well.
Usually, parameters (not variables) are defined in the context of the diagram. If by variables you mean the input signal, then you must create and use a block among possible sources (see sources palette), that will deliver an output to be branched as input to your processing block.

Modifying hex codes to produce a larger output

I was working on this project : http://elm-chan.org/works/sd8p/report.html
and I failed in every possible way from the start. Now that the .Hex files have been uploaded, and the fuses written, when I plugged the SD card in, nothing happened. Nothing at all. Directly asking for a solution might be impossible here as I have no idea what went wrong. So instead I tested the speaker's positive connection with the arduino serial plotter, and I found some interesting results. The output gave some cool irregular pattern of waves,similar to what I would expect from a sound output. But there was no sound, and I suspect that it was because of the output size being too small.(60/1023 is around 0.06 volts, 200/1023 is around 0.2 volts and the bigger output at 500++ levels out, so it shouldn't produce a sound.)
So now I would like to ask whether I can change the fuses of the .hex file(or the hex file itself, but its big.) to produce a larger output. I have not much understanding in hex files or even AVR devices, so any hep at all would be useful.
Thanks in advance.
the graphs
Please let me know if any other information is needed.
Your voltage output on a GPIO pin is limited to your supply voltage, so no you probably can't fix your problem by changing the software or the fuse bits. Depending on your current supply voltage, you might be able to crank that higher, which would increase your voltage output of the PWM, but the supply voltage can only go so high without damaging the chip.
That being said, you need to disconnect the amp and speaker from the AVR and probe the output pin of the PWM and make sure that it is actually producing a signal on that pin. The plots that you posted with that amplitude look like they are nothing but random electrical noise to me.

Source of crackle in phase modulation synthesis

I'm trying to make a simple phase modulation synthesizer based on wavetables and DDS. I have a 12bit wavetable containing 4096 sample of a sine wave and I'm using a 32bit phase accumulator.
Implementing my idea works but it seems to have a lot of low level crackle associated with modulating the depth of phase modulation. I'm generating my sample like so:
Modulator = Modulation*SineWavetable[PhaseAc2>>20];
Sample = SineWavetable[(PhaseAc1 + Modulator)>>20];
I thought the crackle could be generated by modulating the "Modulation" parameter a bit too hard/fast but this doesn't seem to be the cause of the problem. Could anybody enlighten me on potential problems with this method of phase modulation?
As ever, thanks!
As it turns out, typecasting is a very big deal here! I was trying to mix an int32_t (Modulator) with a uint32_t (PhaseAc1) and it was causing strange overflow problems where the phase would momentarily glitch, causing the audible problems. The phase accumulator was calculated outside of the array index section and shifted at a single variable like so:
Modulator = Modulation*SineWavetable[PhaseAc2>>20];
PhaseAc1 += (int32_t)Modulator;
Sample = SineWavetable[(PhaseAc1 + Modulator)>>20];

How can I achieve something similar to Xilinx' RLOC in Altera FPGAs?

I have so far not found any way to do anything similar to Xilinx' RLOC constraints for Altera FPGAs.
Does anyone know a way to do this?
For example place two FFs in the same or adjacent LABs
So to answer my own question, after some consultation with some Altera manuals and some trial and error, I found that this pretty much does what I want.
module synchronizer (input wire dat_i,
input wire out_clk,
output wire dat_o);
(* altera_attribute = "-name SYNCHRONIZATION_REGISTER_CHAIN_LENGTH 2; -name SYNCHRONIZER_IDENTIFICATION \"FORCED IF ASYNCHRONOUS\"" *)
logic [1:0] out_sync_reg;
always_ff#(posedge out_clk) begin
out_sync_reg <= {out_sync_reg[0],dat_i};
end
assign dat_o = out_sync_reg[1];
endmodule
I tested this by setting global synchronizer detection to off and observed that TimeQuest found and analysed the correct paths for metastability.
This works well even when dat_i is latched by clk_a and out_clk is driven by clk_b and where the two clocks are set as:
set_clock_groups -asynchronous -group {clk_a}
set_clock_groups -asynchronous -group {clk_b}
Thus creating false paths between all connections from registers clocked by clk_a to registers clocked by clk_b
set_max/min_delay wont work since it is ignored (as stated by Altera) if the the two clocks are in different asynchronous clock groups.
Altera do not support RLOC style constraints. Apparently this is something to do with the underlying physical architecture. I believe they over-provision ALMs and fuse out columns during chip test to improve yield, therefore relative locations constraints won't translate as expected to a given physical device.
If you are worried about a synchroniser chain placement, you can enable synchroniser chain detection using SYNCHRONIZATION_REGISTER_CHAIN_LENGTH and SYNCHRONIZER_IDENTIFICATION QSF settings (see also this answer).
If you just want to ensure particular timing properties then use set_max_delay and set_min_delay timing constraints on your path.

Resources