Timed exit while loop. Best way?

More
04 Jun 2013 23:38 #35265 by ArcEye
Hi

I think this would be considered real time but I am not sure?

Yes it is realtime

ArcEye, I am building my code based on the Orac Toolchanger you wrote. I am just changing some things to make it work with my setup. The biggest issue I had with the Orac Toolchanger code is from my amateur eyes, contains loops that will go on to infinity if it never gets the right signal.


The Orac does not use a turret clamp signal, it reads the greyscale and divines whether it is at the required position.
Since the required tool position comes up once every 360 degrees it cannot loop forever, it either errors and exits if a false reading is returned or stops when it reads the required tool number.

If you have a signal that may never occur if there is an error, just decide how long you are willing to wait, use a timer for that period, after which abort with a message.
You just need to set a progress_level that tests for the signal and checks the timer and when the timer expires goes to an error state, or if found continues
(see the default: and progress_level 10: in the Orac code which print a message and sit there doing nothing when an error occurs)

The other issue I have with the timer in the Orac file is installing this: sudo comp --install timedelay2.comp The file is nowhere to be found so it says.


That header is out of date sorry, just use the standard timedelay component.
I did write my own initially but decided that was silly and just used the stock one

regards

Please Log in or Create an account to join the conversation.

More
20 Jun 2013 07:55 - 20 Jun 2013 07:55 #35821 by DaOne
Ok I am playing with weighted sum but I feel a bit lost as I cant get it to work correctly. Here is may code in my hal file...
loadrt weighted_sum wsum_sizes=4
addf process_wsums                      servo-thread

net turret-encoder1 wsum.0.bit.0.in <= hm2_5i25.0.gpio.016.in
net turret-encoder2 wsum.0.bit.1.in <= hm2_5i25.0.gpio.017.in
net turret-encoder4 wsum.0.bit.2.in <= hm2_5i25.0.gpio.018.in
net turret-encoder8 wsum.0.bit.3.in <= hm2_5i25.0.gpio.019.in

net sum-out <= wsum.0.sum

I am unable to get sum-out to change in the hal meter and I have verified the gpio pins are working with the hal meter. Any suggestions?
Last edit: 20 Jun 2013 07:55 by DaOne. Reason: typo

Please Log in or Create an account to join the conversation.

More
20 Jun 2013 08:28 #35822 by andypugh

I am unable to get sum-out to change in the hal meter

Is the weighed-sum component added to a thread? And is the thread running?

ie: does weighted_sum appear in an "addf" statement?

Please Log in or Create an account to join the conversation.

More
20 Jun 2013 08:33 #35823 by DaOne
Sorry way too new at this. Where would I look?

Please Log in or Create an account to join the conversation.

More
20 Jun 2013 08:54 #35824 by andypugh
In the HAL file.
You need both a "loadrt" and an "addf" for each component.

Please Log in or Create an account to join the conversation.

More
20 Jun 2013 09:14 #35825 by DaOne
Yes I have
loadrt weighted_sum wsum_sizes=4

in my hal file. I can post the whole thing if thats easier to look at?

Please Log in or Create an account to join the conversation.

More
20 Jun 2013 09:51 #35827 by andypugh
Yes, that might be easier

Please Log in or Create an account to join the conversation.

More
20 Jun 2013 10:01 #35828 by DaOne
Here ya go.. please be gentle I am a newbie ;)
Attachments:

Please Log in or Create an account to join the conversation.

More
20 Jun 2013 10:42 #35830 by andypugh
If you look in your HAL file you will see a "THREADS" section. Every component that has a "loadrt" needs an "addf"
You will need to look at the manual page for each component to see what the functions are called. Some components have a single function for all instances, but most have a function for each instance.
The functions run in the order that they are added to the thread. This sometimes matters. You want to add the functions that feed data to each other in the right order.

Please Log in or Create an account to join the conversation.

More
20 Jun 2013 10:53 #35831 by DaOne
Andy, Thats there just further down. I figured it out. I was defining my input pins wrong. All fixed and I got it going. I sure I will have a million more questions before I complete this project. Thanks again for your help.

Please Log in or Create an account to join the conversation.

Time to create page: 0.079 seconds
Powered by Kunena Forum