PI controllers for 4 motors in a Raspberry Pi 4 - raspberry-pi

I am trying to create a code for a Raspberry Pi4 where I want to control 4 motors (there is not a limited lenguage it could be Python, C or C++ code as long as it works) . I already did the simulation in Simulink with a cascade Pi controllers (3 Pi controllers for control the location and 4 Pi controllers for each motor - I attached an image to be more clear) and the simulation works already good; however, I am not sure how to do it into the Raspberry Pi.
The main idea is that the little car has to move to different given coordinates (X, Y and Z coordinates, but Z is always 0) controlling the positon and the velocities from each motor. My understanding is only to code the Outer PI, Inner PI and the Bi(teta) (see the images I attached) because the motor model, the dynamic model and the kinematic model is done with the robot mobil, so it does not have to be code. In the case of the reference they have to be given in a data sheet (e.g excel file).
The motor driver I am using is two L298N (1 per 2 motors).
Here is the image of the simulation with the cascade P - (https://i.stack.imgur.com/XDrFo.jpg)
Here is the image of the Bi(theta) matrix - (https://i.stack.imgur.com/iMJNU.jpg)
I have never done something like this, if someone can give me a hint or explain me how it can be done I would really appreciate it!!
I hope my explanaition was good enough but if not feel free to ask for a better clarification.
Thanks in advance an have a great day!!

Related

Counting input pulses with a raspberry pi 3 and showing the results

this is my first time working with a raspberry pi and also with structure code( full ladder coding here) My main objective is to connect 4 inputs on my raspberry pi GPIO, I need to count each pulse and display each one of them with a log (date and time) on a web page or any other suggestions to view the data.

How can an Ebike speedsensor regulate the voltage for its throttle?

I want to rebuilt my High-Speed Ebike after it went down.
I tried a Chinese out-of-the-box controller ($40) but it only rotates the 36DC 400W motor at 3 speeds.
Since I want to enhance the bike (GPS, RasPi) I might better intergrate the whole thing, so now I'm thinking of a bare PCB to regulate the speed of the 3 phase motor. Regulation is done by an analogue pot with knob. Could be this one
I'm looking for a way to replace the knob with a electronic version, that takes its input from the speedsensor. This is magnetic switch (Hall?), normal open.
So I'm looking for something that builds up a voltage between 1.8 and 4.9v, depending on the frequency of pulses from the sensor.
I hope this makes sense and somebody is able to get me on track for a solution.
TIA!
It works the other way around. There's no voltage to be 'build up', rather there should be a max voltage (5V) availlable that's dimmed to lower levels by a 10K digital potentiometer. The lever is controlled by a SPI-signal that's generated by the Pi.
Microchip Technology has quite a bunch of them: https://www.microchip.com/paramChartSearch/chart.aspx?branchID=11026
Still have to work this out on a board, though.

Raspberry Pi - More GPIO pins or/and more leds

Like the title said, I need more GPIO pins or just a way to control a lot leds
So I need to control more than 40 leds, or even more, anyway more than raspberry pi has GPIO pins. So I know that there is extension board for Raspberry Pi that extends the GPIO, that's one way to solve it. If anyone ever had one can recommend it to me.
Another idea that I got was to use led matrix but instead use the same idea, I mean for example led row 1 and column 4 or so, but the leds won't be in Grid, instead, they will be separated with wires. But the problem, if we want to do like that:
X O X
O X O
X O X
where X is on and O is off, it's not possible. All leds will be lit up, not like in the pattern. If anyone has the solution to one of the ideas then please share it with me, thank you for your time!
You want to control lots of LEDs using as few GPIO pins as possible.
Solution
The way to do this is to use a technique called Charlieplexing. The name comes from the inventor, Charlie Allen of the company Maxim, and the technique takes advantage of the feature of GPIO pins that allows them to be changed from outputs to inputs while a program is running. When a pin is changed to be an input, not enough current will flow through it to light an LED or influence other pins connected to the LED that are set as outputs.
use breadboard
for more information go to this link
http://razzpisampler.oreilly.com/ch04.html

Anker Astro E4 to power Raspberry Pi

Looking for some help to be honest, This is not my area of knoladge atall.
Ive read around the question of powering my Pi with a battery, now I nabbed one of these guys for my phone
http://www.amazon.co.uk/13000mAh-Portable-External-Technology-Motorola-Black/dp/B00BQ5KHJW/ref=sr_1_cc_1?s=aps&ie=UTF8&qid=1420826597&sr=1-1-catcorr&keywords=anker+astro+e4
Incase the link dies in the future;
Item model number: AK-79AN13K2-BA
AnkerĀ® 2nd Gen Astro E4 13000mAh 2-Port (3A Output) Fast
Max 3A Out
5V Out
Now, from what i've read there have been mixed notes of, don't use batterys, only use this battery, don't do this, don't exeed this magical number ( which was differant each time ). so any help would be grately needed. If i was to power my pi via this thing. im I going to get a poof of smoke and need to replace the poor pi :(
A raspberry Pi is powered via USB, which means that it simply takes the 5V supplied via USB to run. As long as your current source is stable (ie. it doesn't change when you draw current from it), no device will care whether it is a battery or a switching power supply. Now, a bare raspberry Pi B uses less than 2W of power, 2W/5V = 0.4A = 400mA, so if that battery pack lives up to its specification, you are going to be fine. The device is spec'ed to provide 13000mAh, so at a constant current of 400mA, this would last you more than 32 hours.
Now, most people attach something to the raspberry, and that something will also draw power, but just add that power to the calculations above, to see if it's going to work out.

Connecting an accelerometer to a microcontroller pull up voltages

Im trying to connect a MMA852Q accellerometer to a 18F2550 microcontroller. According to accellerometer datasheet i2c clock and data lines would not tolerate voltages more than 1.6- 3.7 (+0.3). Those lines have to be pulled up to 5v for microcntroller to work. Im new in to this subject and your advice to overcome this issue would be really helpful.
You could look for "I2C level shifter" for attaching buses with different voltages together.
NXP appnote 10441 (pdf) has a very neat generic one, for example.