Python Forum
Guidance for how to monitor for a change in a bit state from a hex value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Guidance for how to monitor for a change in a bit state from a hex value
#1
Hello,
I am starting to learn Python, but i come from a controls background.
I have a Beaglebone and just for fun i am using a CanOpen interface with a small servo motor.
I have everything working fine but now i am finding i have to code all the normal features i find as standard in a motion controller ! so its getting interesting

The Problem i am working on :

when you start a servo motor for the first time you "send it home" to find zero, during the homing cycle a 'status word' is sent back continually to the control, in my case the beaglebone.

This statusword HEX value has bit 12 and bit 10 set as 0 or 1 dependent on the condition.

bit 12 and bit 10 both = 0 when the homing operation has started. so i cant move forward in the main program, i must Wait until :-
bit 12 and bit 10 are both = 1 when the homing operation has completed successfully. now i can move forward in the program.

for example i might have the following initially Hex = 4227 Dec = 16935 = bin = 100001000100111
on completion of homing it could change to this Hex = 5627 Dec = 22055 = bin = 101011000100111

I am interested to get opinion on how i might best achieve this type of monitoring as i dont need to change any values, only monitor for change.

while this might be totally obvious solution for people, with my current experience level i want to be sure i follow the best methods.
thank you for all guidance / help
Reply
#2
There's a pretty good write up of various event systems here: https://stackoverflow.com/a/16192256
I don't like pointing to another forum, but this looks like it has good coverage.
Reply
#3
Thank you for this interesting link.

I have also been looking at 'bitflags' would you have any comments on this ?

https://pypi.org/project/bitflag/
Reply
#4
It's not anything that I have needed to use, so can't be of much help.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is it possible to make a program recognize how many clicks it has had on the monitor? jao 0 1,149 Feb-25-2022, 06:31 PM
Last Post: jao
  Need some coding guidance for a task peny 5 2,163 Sep-27-2021, 02:02 PM
Last Post: peny
Sad SyntaxError: from simple python example file from mind-monitor code (muse 2) warmcupoftea 4 2,810 Jul-16-2021, 02:51 PM
Last Post: warmcupoftea
  Your Guidance caslor 1 2,128 Mar-28-2021, 09:34 PM
Last Post: Larz60+
  Monitor specific line of code from website Olimpiarob 1 1,839 Jul-09-2020, 03:20 PM
Last Post: mrdominikku
  Noob needing guidance.... bako 0 1,851 Mar-29-2020, 06:55 PM
Last Post: bako
  psutil for monitor a software finish process and notification Pyguys 0 2,854 Mar-27-2020, 11:15 PM
Last Post: Pyguys
  monitor when a device connects (mac address) drifterf 4 2,816 Jun-29-2019, 12:52 AM
Last Post: Larz60+
  State graph Kaluss 1 2,230 Mar-18-2019, 05:29 PM
Last Post: nilamo
  Function to Continuasly monitor serial port and control other functions ricardons 10 8,124 Mar-04-2018, 10:34 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020