Announcement

Collapse
No announcement yet.

Parallax RFID detector

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Anyone still using this?



    It seems to be a cheep solution.

    Am i over looking anything, besides the code for Homeseer??

    Thanks,
    Rob

    Comment


      #17
      Parallax usb servo controller script

      Just wondering if anyone would be able to edit the script I have or create a script to control a parallax usb servo contoller board. I can fix or build nearly anything mechanical/hardware wise but when it comes to scripts I am totally lost. I would certainly pay for the effort as well. If I am able to get this script I am hoping to share a design for controlling the window blinds in my home. I am actually surprised that I have not seen a script for this yet. Any help would be ImmenselyAppreciated.
      Attached Files

      Comment


        #18
        I'm interested in your blinds solution, i've had a project on the backburner for a while involving stepper motors (built a small pic board and a L239D that I intended to control from HS) to control the tilt on a venetian blind tilt in my lounge, its been on the backburner as I don't think there is not enough torque in my motor - are you using any kind of special servo? I did think about using a servo but went the stepper route...

        I can't help with the actual device as I don't have it, but working on the basis any help is better than nothing (and no guarantee comes with this code), try something like this;

        PHP Code:
        Sub Main()

        Dim id1
        Dim id2
        Dim id3
        Dim hi_value
        Dim lo_value
        Dim ramp_value
        Dim channel
        Dim position

        Dim NEWDATA
        (7)

        id1 P
        id2 
        S
        id3 
        C
        ramp_value 
        7

        '<---- CHANGE THIS TO YOUR CHANNEL ---->
        channel = 0
        '
        <---- CHANGE THIS TO YOUR CHANNEL ---->

        hi_value 1250
        lo_value 
        255
        position 
        500

        NEWDATA
        (0) = CByte(id1)
        NEWDATA(1) = CByte(id2)
        NEWDATA(2) = CByte(id3)
        NEWDATA(3) = CByte(channel)
        NEWDATA(4) = CByte(ramp_value)
        NEWDATA(5) = CByte((position And &HFF))
        NEWDATA(6) = CByte((position And &HFF00) / &H100)
        NEWDATA(7) = &HD

        For Each x in NEWDATA
        SerStr 
        SerStr x
        Next

        hs
        .writelog "ParallaxTest"SerStr

        Dim Success
        Dim Port

        '<---- CHANGE THIS TO YOUR PORT ---->
        Port = 4
        '
        <---- CHANGE THIS TO YOUR PORT ---->

        Success hs.opencomport(Port"2400,N,8,2"1"parallax.txt""Receive")

        If 
        Success "" Then

        hs
        .sendtocomport PortSerStr
        hs
        .writelog "ParallaxTest""Data Sent"
        hs.waitsecs 1
        hs
        .writelog "ParallaxTest""Port Closed"
        hs.closecomport Port

        Else

        hs.writelog "ParallaxTest""Serial port error"

        End If

        End Sub

        Sub Receive
        (Data)

        hs.writelog "ParallaxTest""Following Data Received: " Data

        End Sub 
        Save it as parallax.txt in your scripts directory, change your port and channel accordingly and give it a run - i'd be interested on if the servo moved at all, if it did then could move onto actually making it a more redfined working script, if not then sorry I can't help much further...

        Comment


          #19
          You are awesome, thank you for working on this.

          I am using a HiTec HS-422 Servo. It is nothing great but it's fairly torquey. It's got enough gearing to hold a 2" Faux wood blind at bay. I know after doing so other tests it would not hold a position on a surveillance camera but it would return it once the stress was off. You know how easy it is to twist the stick on a set of blinds! I removed the worm gear to the stick and it appears to work. I researched a whole bunch of gear/ belt driven assy's but wanted to atleast make sure it would work. So it is direct drive temporarily. May have to do some gear reduction if it seems weak. I would think your stepper motor design would be a monster drive for those blinds. I just bought these blinds and wife will kill me if I shredded them. I'll try this script out an let you know. THANK YOU VERY MUCH.

          Comment


            #20
            Mrhappy,

            I know this is a stupid ? but I haven't a clue. How do I create a slider or button to control the servo. I thought maybe you wanted me to just drop the script and restart hs, which I did and thought maybe there was something in the script that would tell it to actuate? Thx...

            Comment


              #21
              Sorry I never replied, the script if you ran it and it did work can be amended to accept a parameter, which can come from a slider/button. It was posted just to see if the communications worked - if it did then a couple of lines could be added to turn the parameter into the position= variable

              Comment


                #22
                OK, could you provide detail on how to add a slider to it. This is where I am really lost. I just do not have a grasp on how scripts work and how to interact with them. Thanks.

                Comment


                  #23
                  Originally posted by Seereus View Post
                  OK, could you provide detail on how to add a slider to it. This is where I am really lost. I just do not have a grasp on how scripts work and how to interact with them. Thanks.
                  Sorry I may have confused things slightly there, sliders/scroll bars are Visual Basic Form Controls (like buttons on a normal windows program), HomeSeer does not use forms for scripts so things like scroll bars are'nt really supported, when you run a script it runs in the background and unless you want to you don't even need to have anything visible - you can instead use either a button on a device or when you run the script you can pass the position for the servo in. I thought you were talking about a slider in HSTouch - which could be used later on to move the servo.

                  That script has the position coded into it, which I was just hoping would move the servo to prove the communication worked and could later be amended, does it do anything if you run it or does any error appear in the log? Just wondering if you get a reply back from the board or not...

                  Comment


                    #24
                    It doesn't move when you run the script but here is what the log shows when I hit run:

                    1/1/2011 3:59:15 PM ParallaxTest Port Closed1/1/2011 3:59:13 PM ParallaxTest Data Sent




                    I just need to know how to add a way to tell it what to do? This is where I am stuck. How do I make it move? What do I use to control the actions of the servo?

                    Comment


                      #25
                      Hmm...probably my bad code, did it come with any software? If so does the board work?

                      I've found this in vb.net http://www.crustcrawler.com/software/psc/index.php which i'm just looking at the sourcecode for to see if its any easier for me to understand.

                      To tell the servo where to go you can do a number of ways (that script I posted the position was 500 [the line position=500] - it was hard coded to move there if you change that to another number like 600 I take it still does not move as I don't think the comms are correct - you can try it though [and I take it you changed the channel and the port correctly?]), how do you want to control it eventually?

                      A common way is to do it via a parameter, what happens then is when you run the script (perhaps from an event) you run it like;

                      &hs.run("parallax.vb", "Main", "50") - to move it to 50
                      &hs.run("parallax.vb", "Main", "200") - to move it to 200

                      But that all depends on getting it to initally to work...

                      Comment


                        #26
                        Ahhh, OK. Let me try that. It does work very well using something like roborealm and chossing the parallax from the device control list. It also works with software from parallax's website. Been a while PSC something...but I know for a fact the servo and the board both work fine.

                        Comment


                          #27
                          Ok, still no response from the servo. You have to remember I am really clueless and can only think I am doing this wrong. Take me step by step through what I need to do. Just putting: &hs.run("parallax.vb", "Main", "50") - to move it to 50 into a text file and running it gives this message in the log: 1/1/2011 4:49:31 PM Error Running script, script run or compile error in file: parallax50.txt1024:Expected statement in line 1 More info: Expected statement

                          Comment


                            #28
                            Its a learning curve for both of us, i'm afraid if this does not work i'm probably out of ideas - i'm sorry (bitten off more than I can chew I think). That vb.net example is pretty complex, but i've had a look at the sourcecode and come up with something else - its a bit of a leap of faith but here goes;

                            Code:
                            Imports System.IO
                            
                            Sub Main(ByVal Parms As Integer)
                            
                            Dim Channel As Integer = 0
                            Dim Ramp As Integer = 7
                            Dim Position As Integer = 500
                            Dim Port As String = "COM9"
                            
                            Dim connection As New IO.Ports.SerialPort
                            
                            connection.portname = port
                            connection.BaudRate = "2400"
                            
                            Try
                            
                            If connection.IsOpen = True Then
                            connection.close()
                            End If
                            
                            connection.Open
                            
                            hs.writelog("Parallax", "Connection Open? " & connection.IsOpen)
                            
                            connection.Write("!SC")
                            Dim data As Byte() = FormatPscPositionCommand(Channel, Ramp, Position)
                            connection.Write(data, 0, 5)
                            connection.Close()
                            
                            Dim i As Integer
                            Dim dataStr As String
                            
                            For i = 0 to Ubound(data)
                            DataStr = DataStr & Data(i)
                            Next
                            
                            hs.writelog("Parallax", "The Data I sent is: " & DataStr)
                            
                            Catch ex As Exception
                            
                            hs.writelog("Error", "Parallax Error: " & ex.message)
                            
                            End Try                    
                            
                            End Sub
                            
                            Public Function FormatPscPositionCommand(ByVal channel As Integer, ByVal ramp As Integer, ByVal postion As Integer) As Byte()
                            	Dim data(4) As Byte
                                    data(0) = CByte(channel)
                                    data(1) = CByte(ramp)
                                    data(2) = CByte((postion And &HFF))
                                    data(3) = CByte((postion And &HFF00) / &H100)
                                    data(4) = &HD
                                    Return data
                            End Function
                            Copy all of that code into notepad, change the following lines;

                            Dim Channel As Integer = 0 <- Change this to your servo channel
                            Dim Port As String = "COM9" <- Change this to your port COM1, COM2, COM3 etc

                            save it as parallax.vb in your scripts directory, then go into the HS control panel and write

                            &hs.run "parallax.vb"

                            Check your log for any errors and/or see what it says - see also if the servo moves, don't worry about the position you are sending at the minute, just want to know if it moves at all or there is any kind've response from the board (status LED?)

                            Comment


                              #29
                              OK here is what posted on the log file:

                              1/1/2011 6:37:06 PM SCR Option Strict OffImports System.IOimports Schedulerimports SystemPublic Module scriptcode22#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin Public WithEvents hs As Scheduler.hsapplication Public WithEvents hsp As scheduler.hsp Public WithEvents hssystem As scheduler.phone0'Event Sources End'End of automatically generated code#End RegionSub Main(ByVal Parms As Integer)Dim Channel As Integer = 0Dim Ramp As Integer = 7Dim Position As Integer = 500Dim Port As String = "COM13"Dim connection As New IO.Ports.SerialPortconnection.portname = portconnection.BaudRate = "2400"TryIf connection.IsOpen = True Thenconnection.close()End Ifconnection.Openhs.writelog("Parallax", "Connection Open? " & connection.IsOpen)connection.Write("!SC")Dim data As Byte() = FormatPscPositionCommand(Channel, Ramp, Position)connection.Write(data, 0, 5)connection.Close()Dim i As IntegerDim dataStr As StringFor i = 0 to Ubound(data)DataStr = DataStr & Data(i)Nexths.writelog("Parallax", "The Data I sent is: " & DataStr)Catch ex As Exceptionhs.writelog("Error", "Parallax Error: " & ex.message)End Try End SubPublic Function FormatPscPositionCommand(ByVal channel As Integer, ByVal ramp As Integer, ByVal postion As Integer) As Byte() Dim data(4) As Byte data(0) = CByte(channel) data(1) = CByte(ramp) data(2) = CByte((postion And &HFF)) data(3) = CByte((postion And &HFF00) / &H100) data(4) = &HD Return dataEnd FunctionCopy all of that code into notepad, change the following End Module1/1/2011 6:37:06 PM Error Script compile error: 'End' statement not valid.on line 681/1/2011 6:37:06 PM Info Running script statement immediately: &hs.run "parallax.vb"

                              I changed the com to 13 as that is where it shows the parallax usb controller. Channel is already in zero, so that's ok. Checked the control board, red power light always on but no activity out of green signal light and servo was idle.

                              I was stoked about running the script I did not answer some of your questions. I basically don't care what controls it whether is automatic or have to do several moves to get it to change. I would just be happy if it worked. You stated to open control panel in homeseer? Not sure what that is, I took it that you meant to create an event an run that so that is what I did. LMK if I should be doing something different. Thank you for all you are doing.

                              Comment


                                #30
                                I think some of that script may have disappeared as it works here without error (its very easy if you copy and paste to miss off something and VB is very unforgiving)...i've attached it to this message with a .txt file extension, save it to your scripts directory and change the extension to a .vb file and give it another run.

                                Don't worry about the control panel, it looks like you are running it correctly (its just a name for the page I think your running it from) whichever way your doing it...

                                I've changed it to COM13 for you so you should just have to run it straight away.
                                Last edited by mrhappy; August 17, 2012, 10:01 AM.

                                Comment

                                Working...
                                X