Hello Guest it is December 10, 2019, 08:02:14 AM

Author Topic: Setting LEDs to show Output activity on CSMIO IP/A  (Read 3437 times)

0 Members and 1 Guest are viewing this topic.

Setting LEDs to show Output activity on CSMIO IP/A
« on: September 28, 2015, 12:05:10 PM »
Hi,

I'm using the CS-Lab CSMIO IP/A Controller, with Mach3. I want to display LEDs to show the state of my outputs.

Can someone advise on the Macro code to use as I'm struggling to get it working at the mo! (Noob)

I know that there are some special VB actions that are used with CSMIO, eg SetCsmioOut and GetCsmioIn so I wondered if there was a GetCsmioOut function?

Many thanks

Mark

Offline Hood

*
  •  25,856 25,856
  • Carnoustie, Scotland
    • View Profile
Re: Setting LEDs to show Output activity on CSMIO IP/A
« Reply #1 on: September 29, 2015, 06:12:31 AM »
What are the LEDs to indicate?
Hood
Re: Setting LEDs to show Output activity on CSMIO IP/A
« Reply #2 on: September 29, 2015, 06:24:41 AM »
On the Controller, there are numerous Outputs that control things like Vacuum relays. Rather than use the standard OUTPUT# options in Port and Pins, these Outputs are switched on and off by using a button on the screen which executes standard basic code. eg, to switch on output 1 on the controller I code:

SetCsmioOut (90, 1)

However, because this output is not represented in Ports/Pins I can't just select that OUTPUT# in the list of options for the LED. Hence the need for a different approach.

I think it should be easy. I already do a similar thing for Input LED indicators using the following code:

====================================================================
Private ind As Integer
Sub Main   
      
   For ind = 0 To 31
      If GetCsmioIn(ind) Then
         SetUserLed((1100 + ind), 1)
      Else
         SetUserLed((1100 + ind), 0)
      End If
   Next ind
   
   If ind > 31 Then
      ind = 0
   End If
   
End Sub   
   
'------------------------------------------------------------------------------------------------------------
'CSMIO/IP-S/A in

Public Function GetCsmioIn (n As Integer) As Boolean
   Dim reg As Integer
   Dim tmp As Integer
   
   tmp = n
   
   If(tmp < 16) Then
      reg = 90
   Else
      reg = 91
      tmp = tmp - 16
   End If
   
   If(GetInBit(reg, tmp)) Then
      GetCsmioIn = true
   Else
      GetCsmioIn = false
   End If
   Exit Function
End Function
=========================================================================

However, I don't think there is a comparable statement of GetCsmioIn for Outputs, ie GetCsmioOut?

Many thanks
Mark

Offline Hood

*
  •  25,856 25,856
  • Carnoustie, Scotland
    • View Profile
Re: Setting LEDs to show Output activity on CSMIO IP/A
« Reply #3 on: September 29, 2015, 06:52:26 AM »
If these LEDs are to be on screen then could you not just add some code to the button to switch a UserLED on?
Hood

Offline Hood

*
  •  25,856 25,856
  • Carnoustie, Scotland
    • View Profile
Re: Setting LEDs to show Output activity on CSMIO IP/A
« Reply #4 on: September 29, 2015, 07:07:01 AM »
User LEDs are from 1000 up so if you add a LED to your screen and set it to OEM code 1000 then you can operate it from VB.
Here is a quick vid showing me switching it on sleep for 1 second then switch off.
https://youtu.be/no6_mzRJx4Q

Hood
Re: Setting LEDs to show Output activity on CSMIO IP/A
« Reply #5 on: September 29, 2015, 09:19:56 AM »
Hi Hood,

Thanks for the tips. It was working OK but I have a weird bug. See attached vid. https://youtu.be/YVt0htx6DgY

Basically if I run the code in the script window it works. But if I press the button to run the code in Mach3, it doesn't work!

I wondered if it is because I have more than one LED with the same User Defined reference?

Can you spot the bug in my code?

Also, I think it would be best if I can just read the state of my Outputs in the Controller. I'm surprised there doesn't appear to be an easy way to do it.

Many thanks
Mark
Re: Setting LEDs to show Output activity on CSMIO IP/A
« Reply #6 on: September 29, 2015, 09:44:22 AM »
Don't worry - I found the problem - it was the screen button covering the LED up. If I moved the LED to a different part of the screen with no other features, then it worked OK.

Now I just need to play around with my MachScreen layout to get it to appear in the place I want it to!

Mark

Offline Hood

*
  •  25,856 25,856
  • Carnoustie, Scotland
    • View Profile
Re: Setting LEDs to show Output activity on CSMIO IP/A
« Reply #7 on: September 29, 2015, 01:18:05 PM »
Just had a look at the vid, are your buttons below the LED or surrounding the LED or similar?
If so then I don't think you will get it to work. Brett and myself had similar issues when trying to design our respective screens with buttons integrated LEDs.
Here is what we came up with, pic below of a section of my screen as viewed normally and the same section of it viewed in screen4 and two of the  actual LED images showing the two states.
What you are seeing is the part that looks like a button is actually a LED and the button is an image button with no image, so in effect invisible. This invisible button can not cover the actual LED or it will not show state changes hence the reason the invisible buttons just cover the lower section of the LED.
Hood
« Last Edit: September 29, 2015, 01:23:15 PM by Hood »