**RESOLVED** Writing Brains For Spindle and TC?

All things related to Centroid Oak, Allin1DC, MPU11 and Legacy products

Moderator: cnckeith

diycncscott

Re: How do you set a user led in brains??

Post by diycncscott »

please no smoke wrote:How do you set a user led in brains??
Now THAT is the type of question I like to see...

Reading, Setting and Resetting a UserLED in a Brain

As the title suggests, this example shows you how to read, set or reset a UserLED in a Brain. The standard Brains disclaimer applies: If you assign a value to I/O, LED, variable etc... in a Brain, it can only be assigned once if you expect to use it reliably. That's once as in only on this line, in this Brain. It can't reliably be assigned a value again either in the same Brain, or in another Brain or Macro. See this write up for information: Brains Vs. Macros – How To Decide

For more detailed information on Brains programming in Mach, please see http://www.machsupport.com.

In the Brain below, we are in the process of writing logic that will assigning a value to UserLED #1000 based on the state of Ajax input #1 (Modbus input 1, bit only). UserLED's are assigned a number of from 1000-2255. To read or assign a value to an UserLED you must check the box “Use LED number” and then type a value of between 1000-2255 to specify which UserLED you wish to use.

NOTE: When using a UserLED in a Brain, the Brain editor may label it as an “OEMLED). The label is incorrect as, by definition, LED's 1000 and above are user LED's. The label assigned in the editor is irrelevant, simply refer to the LED by it's number to read, set or reset it.

When finished, this Brain will reset UserLED #1000 (assign a value of 0) if Ajax input #1 is open, and it will set UserLED#1000 (assign a value of 1) if Ajax input #1 is closed. Please note that the single line of code sets the LED when true and resets when false.
defineuserled.gif
please no smoke
Posts: 103
Joined: Mon Mar 29, 2010 10:17 pm

Re: Writing Brains For Spindle and TC?

Post by please no smoke »

Scott did you finish that above reply or did it post wrong?? If not, can we get a screen shot of the completed program?

Also, is this still a problem, as it pertains to setting led's in brains? (see below)


from"poppabear" manual....


"3. When you bring in a Modbus input that goes to an UserLED in Mach, you will need to do a “Invert Op lobe”, for it to turn on the mach screen, so the Brain will show the ULED as off when the modbus input is on, but the actual ULED on the Mach screen will be on."

Thanks

Matt
diycncscott

Setting a UserLED in a Brain

Post by diycncscott »

Matt,

Most of the "Modbus" specific stuff doesn't apply. We only use the Mach mapping for the I/O ie.. our input #1 = the same Mach bit that Mach would associate with what it thinks is Modbus input #1. We don't use "Modbus" at all. It's too slow

If you read what I posted and follow the example(s) I posted, you will see that it works as listed. The only thing "missing" is clicking "ok" to finish the lobe/rung as shown in the screen shot. I left that "unfinished" so you could still see how the UserLED was defined when terminating the lobe.
Locked