06-06-2016 07:24 AM - edited 06-06-2016 07:25 AM
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)))
06-06-2016 07:34 AM
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...
06-06-2016 07:57 AM
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
06-06-2016 08:24 AM
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
06-06-2016 09:07 AM
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
06-06-2016 11:36 AM - edited 06-06-2016 11:42 AM
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
06-06-2016 12:13 PM