LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fpga servo motor+ultrasonic

hello everyone, i'm working on a project for robot obstacle avoidance, i'm using fpga on myrio to control the position of the servo motor which sweeps a certain area defined by theta min and theta max with a step theta, an ultrasonic sensor is mounted on the servo and should take a distance reading at each step angle. the current position angle and its corresponding distance reading should be synchronised and corresponding to each other. then i will take this data to a host vi which is not a problem.

i was able to operate and control the servo motor as i want and i was able to get the readings from the ultrasonic sensor (i have hc sr04 and ping) on the fpga separately, however, when i try to make them both work at the same time, i have no luck doing so.... i have tried many things and searched all over.... can anyone please guide me what to do?.... i have attached the last fpga code that i came up with, i dont know what is wrong with it.... thanks)))

0 Kudos
Message 1 of 7
(4,258 Views)

I am not sure to completely understand your question, but I have just some suggestions about your code.

-Avoid coercion dot points (red points);

- Why have you  put your PWM loop inside a for loop? This increases a lot the FPGA complexity and maybe coud lead the code to an unexpected behaviour. Couldn't put it in parallel to the main loop? I guess the two funcionalities (operating servo motor and reading values) should go in parallel...

 

 

0 Kudos
Message 2 of 7
(4,246 Views)

i tried putting them in parallel, but how can i make sure that the angle position corresponds to a certain distance reading, because the parallel loops will have different timings. so i tried to put them in a sequence but this didnt work either

0 Kudos
Message 3 of 7
(4,233 Views)

maybe trying to enable/disable the parallel reading with a boolean semaphore could help

see attached pic (not sure about your LV version) - don't mind the broken wires

0 Kudos
Message 4 of 7
(4,222 Views)

ok, thanks for your help....i tried something similar but using occurrences and sequences but for some reason the while loop didnt give any readings but  i will try what you suggested and compile and let u know

0 Kudos
Message 5 of 7
(4,199 Views)

thank you Marco for your help, seems to be working now 🙂 ..... but another thing happened.... that the "frequency" control which controls the timings in the sequence inside the for loop doesnt seem to have any effect... which is making the servo motor vibrates because it is not running on the right frequency

0 Kudos
Message 6 of 7
(4,169 Views)
Probably the while loop which we have put in parallel was generating a fixed delay inside your for loop. try to put a similar delay inside the for loop in place of the while that we removed!
0 Kudos
Message 7 of 7
(4,158 Views)