Loading ...
Sorry, an error occurred while loading the content.

RE: [ASCOM] Bit of help writing Focuser Driver using VB

Expand Messages
  • Tim Long
    ... I think you mean Absolute (as opposed to Relative). Absolute positioning is really an attribute determined by your hardware design. An absolute focuser
    Message 1 of 16 , Mar 3, 2008
    • 0 Attachment
      > PIC code. Is there any advantage to using either a relative of actual
      > focuser?
      >
      > Regards,
      >
      > Markus
      >

      I think you mean Absolute (as opposed to Relative).

      Absolute positioning is really an attribute determined by your hardware
      design. An absolute focuser knows what position it is in when you turn
      the power on. A relative focuser does not know its position when you
      turn the power on, so it can only be positioned "relative to where it is
      now". Some relative devices can act as if they are absolute, provided
      some special procedure is observed. RoboFocus, for example, remembers
      its last position in non-volatile memory when the power is turned off,
      so provided the mechanism is never moved manually, it can provide
      absolute positioning. Slipping a clutch would invalidate your reference
      point though.

      To make your focuser absolute, you can either use an absolute shaft
      encoder, or you can provide some means of detecting a known fixed
      reference position. The Optec TCF, for example, is inherently a relative
      design (albeit very high quality with good repeatability). When the
      power is turned on, the firmware moves the focuser all the way in to the
      limit of travel, establishing a known fixed reference point at
      position=0000. The TCF has no idea what position it is in when the power
      is turned on, but with clever use of firmware, the device calibrates
      itself and therefore becomes effectively capable of absolute
      positioning. Thereafter, the device can be positioned directly to any
      point from 0000 to 7000. Another way to achieve this would be to use an
      optical sensor and a moving vane on the focuser mechanism that breaks
      the beam at a known position.

      -Tim
    • R Hamlett
      ... There are really another set of terms , that apply. Closed loop, and open loop. The RoboFocus, is an absolute focusser (it moves by a precise amount for
      Message 2 of 16 , Mar 4, 2008
      • 0 Attachment
        >> PIC code. Is there any advantage to using either a relative of actual
        >> focuser?
        >>
        >> Regards,
        >>
        >> Markus
        >>
        >
        > I think you mean Absolute (as opposed to Relative).
        >
        > Absolute positioning is really an attribute determined by your hardware
        > design. An absolute focuser knows what position it is in when you turn
        > the power on. A relative focuser does not know its position when you
        > turn the power on, so it can only be positioned "relative to where it is
        > now". Some relative devices can act as if they are absolute, provided
        > some special procedure is observed. RoboFocus, for example, remembers
        > its last position in non-volatile memory when the power is turned off,
        > so provided the mechanism is never moved manually, it can provide
        > absolute positioning. Slipping a clutch would invalidate your reference
        > point though.
        >
        > To make your focuser absolute, you can either use an absolute shaft
        > encoder, or you can provide some means of detecting a known fixed
        > reference position. The Optec TCF, for example, is inherently a relative
        > design (albeit very high quality with good repeatability). When the
        > power is turned on, the firmware moves the focuser all the way in to the
        > limit of travel, establishing a known fixed reference point at
        > position=0000. The TCF has no idea what position it is in when the power
        > is turned on, but with clever use of firmware, the device calibrates
        > itself and therefore becomes effectively capable of absolute
        > positioning. Thereafter, the device can be positioned directly to any
        > point from 0000 to 7000. Another way to achieve this would be to use an
        > optical sensor and a moving vane on the focuser mechanism that breaks
        > the beam at a known position.
        >
        > -Tim
        There are really another set of 'terms', that apply. Closed loop, and
        open loop. The RoboFocus, is an 'absolute' focusser (it moves by a
        precise amount for each 'step'), but it is an 'open loop' focusser
        (hence cannot tell if it has reached a physical end stop, or if a clutch
        has moved). The 'ideal' focusser, would be absolute, closed-loop. I have
        built a number of focussers like this, using the RoboFocus software
        interface, but with optical encoders, and precision servos. Then, as
        'second choice', you would have absolute, open-loop, with home
        detection. This is the behaviour of the RC focusser, or their instrument
        rotator, and the TCF descibed above. With these, though it is still
        impossible to detect 'error' events, during movements, it is possible to
        reset, and work from a known starting point at any time. Then as 'third
        choice', you have absolute, fully open-loop (the normal RoboFocus). Then
        (potentially), you could have a relative focusser, with a home detector
        (I don't know of anyone doing this), and finally, relative open-loop
        (the normal simple DC motor focussers). You also have variability here,
        in how accurately the motor responds to power for a given time, and how
        quickly it can be braked (affects for example, the Meade focusser, as
        you move to different parts of the sky, and loading changes). It is
        possible to produce quite accurate 'relative' focussers, and also
        absolutely appalling ones.
        For each possible 'type', there is a range of implementations, and (for
        example), for most users, the RoboFocus, behaves 'close enough' to an
        ideal focusser, to work well.

        Best Wishes
      • peterjchance
        I hope you guys don t mind me jumping in at this point but I am in a simliar situation to Marcus in that I also intend to use a pic chip to control a focuser
        Message 3 of 16 , Mar 4, 2008
        • 0 Attachment
          I hope you guys don't mind me jumping in at this point but I am in a
          simliar situation to Marcus in that I also intend to use a pic chip
          to control a focuser and am having some trouble with the VB code for
          the simulator.

          I have no problem with the pic stuff and am quite comfortable with
          VB6, but this is my first venture with vb.net (vb 2005).

          I have already used the simulator template to set up my application
          and I can see and select my focuser in the chooser when I run MaxIm.
          I have also been able to run the application in debug mode and can
          step through the code.

          What I am having trouble with, and to be honest this is no doubt
          purely my lack of knowledge with vb.net, is how to set a variable
          such as MaxStep.

          MaxStep is read only and according to the books the only way to set a
          value for a read only property is to define it in the constructor.
          The constructor appears to be at the top of the program, and implies
          that my code should be in the following routine:

          Public Sub New()

          IFocuser.MaxStep = 1000 ' My code

          ' TODO Implement your additional construction here
          End Sub

          Whatever I do, however, and I have tried many things, the program
          still gives an error saying that MaxStep is read only.

          Can anyone shed some light on this matter to get me on the right
          track?

          Regards

          Peter


          --- In ASCOM-Talk@yahoogroups.com, "Larry Weber" <larryweber@...>
          wrote:
          >
          > Markus,
          >
          > I think Tim makes a good point.
          >
          > One fun way to climb this learning curve is to take the VB source
          code for the Focuser Simulator and then run it in VB under debug
          mode. For starters, I would put a breakpoint at the beginning of
          each subroutine in the Focuser Class. Then get some program that can
          control ASCOM focusers such as MaxIm DL or FocusMax, and connect one
          of them to the Focuser Simulator. When you do this with the Focuser
          Simulator source code running under VB in debug mode, a focuser
          operation that is initiated in MaxIm or FocusMax will talk to the
          version of Focuser Simulator that you are running in debug mode. Any
          command initiated by MaxIm or FocusMax will hit one of the
          breakpoints you have set. You can step through the source code,
          examine the variables and see how it all works.
          >
          > Once you get through this exercise, you can make your own version
          of the Focuser Simulator and put in some of the code for your
          focuser. Pick the Focuser class Move subroutine first and put in
          some code that will cause your focuser to move. Maxim has a feature
          for manually moving the focuser under Telescope Control on the
          Focuser tab. Or you could click the Jog button in FocusMax to do
          manual control. Any way you do it, you will gain confidence and
          learn a lot just by seeing your focuser move under the control of
          either MaxIm or FocusMax.
          >
          > Larry
          >
          >
          >
          >
          >
          >
          >
          >
          > ----- Original Message -----
          > From: Tim Long
          > To: ASCOM-Talk@yahoogroups.com
          > Sent: Sunday, March 02, 2008 2:44 PM
          > Subject: RE: [ASCOM] Bit of help writing Focuser Driver using VB
          >
          >
          >
          > I think you really need to read through the ASCOM focuser
          standard and get an understanding of what all the properties and
          methods are supposed to do. You then have to add your own code to
          each property and method that is applicable to your device to make it
          perform as described in the standards document.
          >
          >
          >
          > --Tim
          >
          >
          >
          > From: ASCOM-Talk@yahoogroups.com [mailto:ASCOM-
          Talk@yahoogroups.com] On Behalf Of billerwellm
          > Sent: 02 March 2008 07:51
          > To: ASCOM-Talk@yahoogroups.com
          > Subject: [ASCOM] Bit of help writing Focuser Driver using VB
          >
          >
          >
          > Hi,
          >
          > It's my first time writing a driver and my VB experience is very
          little. I have built a focuser using a servo motor and have it
          controlled via a slide bar GUI using VB (not ASCOM compliant). Please
          see below:-
          >
          > Option Explicit
          >
          > Private Sub Form_Load()
          >
          > 'These are key properties in controlling
          > 'scrolling behavior
          >
          > VScroll1.SmallChange = 1 'how much to change value on arrow click
          > VScroll1.LargeChange = 15 'how much to change value on scroll
          > VScroll1.Min = 117 'minimum value (set to text box top)
          > VScroll1.Max = 195 'maximum value (set to text box height
          >
          > VScroll1.Value = 157 'set vscroll mid start point
          > Text2(0).Text = VScroll1.Value
          >
          > With MSComm1
          > 'make sure the serial port is not open (by this program)
          > If .PortOpen Then .PortOpen = False
          > 'set the active serial port
          > .CommPort = 1
          > 'set the badurate,parity,databits,stopbits for the connection
          > .Settings = "9600,N,8,1"
          > 'set the DRT and RTS flags
          > .DTREnable = True
          > .RTSEnable = True
          > 'enable the oncomm event for every reveived character
          > .RThreshold = 1
          > 'disable the oncomm event for send characters
          > .SThreshold = 0
          > 'open the serial port
          > .PortOpen = True
          > End With 'MSComm1
          >
          > End Sub
          >
          >
          > Private Sub VScroll1_Change()
          >
          > Text2(0).Text = VScroll1.Value ' provides reset slide bar value
          >
          > With MSComm1
          > 'make sure the serial port is open
          > If .PortOpen = False Then .PortOpen = True
          > 'send the data (including a tailing carriage return as often
          needed)
          > .Output = Chr$(1) ' Select which servo to drive
          > .Output = Chr$(VScroll1.Value)
          > End With 'MSComm1
          >
          > VScroll1.Value = 157
          > Text2(0).Text = VScroll1.Value ' provides reset slide bar value
          >
          > End Sub
          >
          >
          > Private Sub VScroll1_Scroll()
          > Text2(0).Text = VScroll1.Value ' provides reset slide bar value
          >
          > With MSComm1
          > 'make sure the serial port is open
          > If .PortOpen = False Then .PortOpen = True
          > 'send the data (including a tailing carriage return as often
          needed)
          > .Output = Chr$(1) ' Select which servo to drive
          > .Output = Chr$(VScroll1.Value)
          > End With 'MSComm1
          >
          > End Sub
          >
          >
          > Basically a couple of values are sent to the PIC using the
          `MSComm1.Output' command to tell the servo what to do via a com port.
          >
          > I have downloaded and set up the focuser template from ASCOM but
          I have no idea what code to put in the TODO areas. Say in the case of
          the code below, am I right in assuming (please tell me if I'm wrong)
          I just put a set value in place of the TODO sentence relating to my
          focuser for what ever controlling software is wanting to speak to the
          focuser? If so what should the code defining that value look like?
          >
          > Public ReadOnly Property MaxStep() As Integer Implements
          IFocuser.MaxStep
          > ' TODO Replace this with your implementation
          > Get
          > Throw New PropertyNotImplementedException("MaxStep",
          False)
          > End Get
          > End Property
          >
          > Same with the next bit of code. I assume (once again please tell
          me if I'm wrong) this TODO requires me to use a values that it sent
          to my driver and move my focuser that amount. Is this where I would
          use the 'MSComm1.Output' command to send the value to the PIC.
          >
          > Public Sub Move(ByVal val As Integer) Implements IFocuser.Move
          > ' TODO Replace this with your implementation
          > Throw New MethodNotImplementedException("Move")
          > End Sub
          >
          > The rest of the template is pretty much down the same path. So
          if I get an understanding of these 2 I should hopefully be able to
          work out the rest. I have looked around for some completed focuser
          code using the ASCOM template without any luck. If anyone can direct
          me to some it would be much appreciated. Otherwise if someone could
          please show me an example of what I could put in the TODO parts that
          would be great also.
          >
          > Thanks for taking to time to read my question.
          >
          > Cheers,
          >
          > Markus
          >
        • billerwellm
          Thank you both for your explanations, and yes Tim I did mean Absolute (another one of my dyslexic moments :/ ) My thought of making an Absolute focuser was
          Message 4 of 16 , Mar 5, 2008
          • 0 Attachment
            Thank you both for your explanations, and yes Tim I did mean Absolute
            (another one of my dyslexic moments :/ )

            My thought of making an Absolute focuser was going to be similar to
            the Optec TCF type of focuser you mentioned, where I would use some
            sort of mechanical or electrical sensor to aid in placing the focuser
            in the 0000 position at either turn on or turn off. This would work
            fine for an initial start point but as mentioned doesn't protect from
            inaccuracies caused by possible slippage between the drive rod and the
            flat face of the focuser tube.

            All that aside, what are the additional benefits in using something
            like a closed loop absolute focuser compared to an accurate stepping
            relative focuser when I'm using something like FocusMax. Won't
            FocusMax just move either focuser the set step allocated to the
            focuser to the preferred location based on its assessment of the
            pictures taken? How does knowing exactly where the focuser is
            positioned aid FocusMax when to my understanding (a limited
            understanding :) ) FocusMax doesn't care? Or does it?

            Regards.




            --- In ASCOM-Talk@yahoogroups.com, R Hamlett <ttelmah@...> wrote:
            >
            > >> PIC code. Is there any advantage to using either a relative of actual
            > >> focuser?
            > >>
            > >> Regards,
            > >>
            > >> Markus
            > >>
            > >
            > > I think you mean Absolute (as opposed to Relative).
            > >
            > > Absolute positioning is really an attribute determined by your
            hardware
            > > design. An absolute focuser knows what position it is in when you turn
            > > the power on. A relative focuser does not know its position when you
            > > turn the power on, so it can only be positioned "relative to where
            it is
            > > now". Some relative devices can act as if they are absolute, provided
            > > some special procedure is observed. RoboFocus, for example, remembers
            > > its last position in non-volatile memory when the power is turned off,
            > > so provided the mechanism is never moved manually, it can provide
            > > absolute positioning. Slipping a clutch would invalidate your
            reference
            > > point though.
            > >
            > > To make your focuser absolute, you can either use an absolute shaft
            > > encoder, or you can provide some means of detecting a known fixed
            > > reference position. The Optec TCF, for example, is inherently a
            relative
            > > design (albeit very high quality with good repeatability). When the
            > > power is turned on, the firmware moves the focuser all the way in
            to the
            > > limit of travel, establishing a known fixed reference point at
            > > position=0000. The TCF has no idea what position it is in when the
            power
            > > is turned on, but with clever use of firmware, the device calibrates
            > > itself and therefore becomes effectively capable of absolute
            > > positioning. Thereafter, the device can be positioned directly to any
            > > point from 0000 to 7000. Another way to achieve this would be to
            use an
            > > optical sensor and a moving vane on the focuser mechanism that breaks
            > > the beam at a known position.
            > >
            > > -Tim
            > There are really another set of 'terms', that apply. Closed loop, and
            > open loop. The RoboFocus, is an 'absolute' focusser (it moves by a
            > precise amount for each 'step'), but it is an 'open loop' focusser
            > (hence cannot tell if it has reached a physical end stop, or if a
            clutch
            > has moved). The 'ideal' focusser, would be absolute, closed-loop. I
            have
            > built a number of focussers like this, using the RoboFocus software
            > interface, but with optical encoders, and precision servos. Then, as
            > 'second choice', you would have absolute, open-loop, with home
            > detection. This is the behaviour of the RC focusser, or their
            instrument
            > rotator, and the TCF descibed above. With these, though it is still
            > impossible to detect 'error' events, during movements, it is
            possible to
            > reset, and work from a known starting point at any time. Then as 'third
            > choice', you have absolute, fully open-loop (the normal RoboFocus).
            Then
            > (potentially), you could have a relative focusser, with a home detector
            > (I don't know of anyone doing this), and finally, relative open-loop
            > (the normal simple DC motor focussers). You also have variability here,
            > in how accurately the motor responds to power for a given time, and how
            > quickly it can be braked (affects for example, the Meade focusser, as
            > you move to different parts of the sky, and loading changes). It is
            > possible to produce quite accurate 'relative' focussers, and also
            > absolutely appalling ones.
            > For each possible 'type', there is a range of implementations, and (for
            > example), for most users, the RoboFocus, behaves 'close enough' to an
            > ideal focusser, to work well.
            >
            > Best Wishes
            >
          • billerwellm
            Thank you both for your explanations, and yes Tim I did mean Absolute (another one of my dyslexic moments :/ ) My thought of making an Absolute focuser was
            Message 5 of 16 , Mar 5, 2008
            • 0 Attachment
              Thank you both for your explanations, and yes Tim I did mean Absolute
              (another one of my dyslexic moments :/ )

              My thought of making an Absolute focuser was going to be similar to
              the Optec TCF type of focuser you mentioned, where I would use some
              sort of mechanical or electrical sensor to aid in placing the focuser
              in the 0000 position at either turn on or turn off. This would work
              fine for an initial start point but as mentioned doesn't protect from
              inaccuracies caused by possible slippage between the drive rod and the
              flat face of the focuser tube.

              All that aside, what are the additional benefits in using something
              like a closed loop absolute focuser compared to an accurate stepping
              relative focuser when I'm using something like FocusMax (apart from
              exceeding the limits of the focuser). Won't FocusMax just move either
              focuser the set step allocated to the focuser to the preferred
              location based on its assessment of the pictures taken? How does
              knowing exactly where the focuser is positioned aid FocusMax when to
              my understanding (a limited understanding :) ) FocusMax doesn't care?
              Or does it?

              Regards.



              > --- In ASCOM-Talk@yahoogroups.com, R Hamlett <ttelmah@> wrote:
              > >
              > > >> PIC code. Is there any advantage to using either a relative of
              actual
              > > >> focuser?
              > > >>
              > > >> Regards,
              > > >>
              > > >> Markus
              > > >>
              > > >
              > > > I think you mean Absolute (as opposed to Relative).
              > > >
              > > > Absolute positioning is really an attribute determined by your
              > hardware
              > > > design. An absolute focuser knows what position it is in when
              you turn
              > > > the power on. A relative focuser does not know its position when you
              > > > turn the power on, so it can only be positioned "relative to where
              > it is
              > > > now". Some relative devices can act as if they are absolute,
              provided
              > > > some special procedure is observed. RoboFocus, for example,
              remembers
              > > > its last position in non-volatile memory when the power is
              turned off,
              > > > so provided the mechanism is never moved manually, it can provide
              > > > absolute positioning. Slipping a clutch would invalidate your
              > reference
              > > > point though.
              > > >
              > > > To make your focuser absolute, you can either use an absolute shaft
              > > > encoder, or you can provide some means of detecting a known fixed
              > > > reference position. The Optec TCF, for example, is inherently a
              > relative
              > > > design (albeit very high quality with good repeatability). When the
              > > > power is turned on, the firmware moves the focuser all the way in
              > to the
              > > > limit of travel, establishing a known fixed reference point at
              > > > position=0000. The TCF has no idea what position it is in when the
              > power
              > > > is turned on, but with clever use of firmware, the device calibrates
              > > > itself and therefore becomes effectively capable of absolute
              > > > positioning. Thereafter, the device can be positioned directly
              to any
              > > > point from 0000 to 7000. Another way to achieve this would be to
              > use an
              > > > optical sensor and a moving vane on the focuser mechanism that
              breaks
              > > > the beam at a known position.
              > > >
              > > > -Tim
              > > There are really another set of 'terms', that apply. Closed loop, and
              > > open loop. The RoboFocus, is an 'absolute' focusser (it moves by a
              > > precise amount for each 'step'), but it is an 'open loop' focusser
              > > (hence cannot tell if it has reached a physical end stop, or if a
              > clutch
              > > has moved). The 'ideal' focusser, would be absolute, closed-loop. I
              > have
              > > built a number of focussers like this, using the RoboFocus software
              > > interface, but with optical encoders, and precision servos. Then, as
              > > 'second choice', you would have absolute, open-loop, with home
              > > detection. This is the behaviour of the RC focusser, or their
              > instrument
              > > rotator, and the TCF descibed above. With these, though it is still
              > > impossible to detect 'error' events, during movements, it is
              > possible to
              > > reset, and work from a known starting point at any time. Then as
              'third
              > > choice', you have absolute, fully open-loop (the normal RoboFocus).
              > Then
              > > (potentially), you could have a relative focusser, with a home
              detector
              > > (I don't know of anyone doing this), and finally, relative open-loop
              > > (the normal simple DC motor focussers). You also have variability
              here,
              > > in how accurately the motor responds to power for a given time,
              and how
              > > quickly it can be braked (affects for example, the Meade focusser, as
              > > you move to different parts of the sky, and loading changes). It is
              > > possible to produce quite accurate 'relative' focussers, and also
              > > absolutely appalling ones.
              > > For each possible 'type', there is a range of implementations, and
              (for
              > > example), for most users, the RoboFocus, behaves 'close enough' to an
              > > ideal focusser, to work well.
              > >
              > > Best Wishes
              > >
              >
            • Tim Long
              There isn t enough information to go on from the snippet you posted, but it looks like you re trying to write to the interface, which cannot work because
              Message 6 of 16 , Mar 5, 2008
              • 0 Attachment

                There isn't enough information to go on from the snippet you posted, but it looks like you're trying to write to the interface, which cannot work because interfaces are abstract definitions with no executable code in them. If you used the template focuser project provided with Platform 5, then you should have a bunch of methods and properties within a #region called "IFocuser members". One of those properties is MaxStep, defined as follows:

                 

                       Public ReadOnly Property MaxStep() As Integer Implements IFocuser.MaxStep

                              ' TODO Replace this with your implementation

                              Get

                                      Throw New PropertyNotImplementedException("MaxStep", False)

                              End Get

                       End Property

                 

                 

                You need to edit that code to simply return your MaxStep value. So if your MaxStep was 5000, you might do something like:

                 

                       Public ReadOnly Property MaxStep() As Integer Implements IFocuser.MaxStep

                              ' TODO Replace this with your implementation

                              Get

                                     Return 5000

                              End Get

                       End Property

                 

                 

                 

                Best regards,

                Microsoft Most Valuable ProfessionalTiger Relief.png

                Tim Long

                Owner & Technology Consultant

                TiGra Networks

                The Small Business IT Specialists

                01443 208678 | www.tigranetworks.co.uk

                 

                 

                 

                 

                > -----Original Message-----

                > From: ASCOM-Talk@yahoogroups.com

                [mailto:ASCOM-Talk@yahoogroups.com] On

                > Behalf Of peterjchance

                > Sent: 05 March 2008 00:14

                > To: ASCOM-Talk@yahoogroups.com

                > Subject: Re: [ASCOM] Bit of help

                writing Focuser Driver using VB

                >

                > I hope you guys don't mind me jumping in at this

                point but I am in a

                > simliar situation to Marcus in that I also intend to

                use a pic chip

                > to control a focuser and am having some trouble with

                the VB code for

                > the simulator.

                >

                > I have no problem with the pic stuff and am quite

                comfortable with

                > VB6, but this is my first venture with vb.net (vb

                2005).

                >

                > I have already used the simulator template to set up

                my application

                > and I can see and select my focuser in the chooser

                when I run MaxIm.

                > I have also been able to run the application in

                debug mode and can

                > step through the code.

                >

                > What I am having trouble with, and to be honest this

                is no doubt

                > purely my lack of knowledge with vb.net, is how to

                set a variable

                > such as MaxStep.

                >

                > MaxStep is read only and according to the books the

                only way to set a

                > value for a read only property is to define it in

                the constructor.

                > The constructor appears to be at the top of the

                program, and implies

                > that my code should be in the following routine:

                >

                >     Public Sub New()

                >

                >         IFocuser.MaxStep

                = 1000 ' My code

                >

                >         '

                TODO Implement your additional construction here

                >     End Sub

                >

                > Whatever I do, however, and I have tried many

                things, the program

                > still gives an error saying that MaxStep is read

                only.

                >

                > Can anyone shed some light on this matter to get me

                on the right

                > track?

                >

                > Regards

                >

                > Peter

                >

                >

                > --- In ASCOM-Talk@yahoogroups.com, "Larry

                Weber" <larryweber@...>

                > wrote:

                > >

                > > Markus,

                > >

                > > I think Tim makes a good point.

                > >

                > > One fun way to climb this learning curve is to

                take the VB source

                > code for the Focuser Simulator and then run it in VB

                under debug

                > mode.  For starters, I would put a breakpoint

                at the beginning of

                > each subroutine in the Focuser Class.  Then get

                some program that can

                > control ASCOM focusers such as MaxIm DL or FocusMax,

                and connect one

                > of them to the Focuser Simulator.  When you do

                this with the Focuser

                > Simulator source code running under VB in debug

                mode, a focuser

                > operation that is initiated in MaxIm or FocusMax

                will talk to the

                > version of Focuser Simulator that you are running in

                debug mode.  Any

                > command initiated by MaxIm or FocusMax will hit one

                of the

                > breakpoints you have set.  You can step through

                the source code,

                > examine the variables and see how it all works.

                > >

                > > Once you get through this exercise, you can

                make your own version

                > of the Focuser Simulator and put in some of the code

                for your

                > focuser.  Pick the Focuser class Move

                subroutine first and put in

                > some code that will cause your focuser to

                move.  Maxim has a feature

                > for manually moving the focuser under Telescope

                Control on the

                > Focuser tab.  Or you could click the Jog button

                in FocusMax to do

                > manual control.  Any way you do it, you will

                gain confidence and

                > learn a lot just by seeing your focuser move under

                the control of

                > either MaxIm or FocusMax.

                > >

                > > Larry

                > >

                > >

                > >

                > >

                > >

                > >

                > >

                > >

                > >   ----- Original Message -----

                > >   From: Tim Long

                > >   To: ASCOM-Talk@yahoogroups.com

                > >   Sent: Sunday, March 02, 2008 2:44

                PM

                > >   Subject: RE: [ASCOM] Bit of help

                writing Focuser Driver using VB

                > >

                > >

                > >

                > >   I think you really need to read

                through the ASCOM focuser

                > standard and get an understanding of what all the

                properties and

                > methods are supposed to do. You then have to add

                your own code to

                > each property and method that is applicable to your

                device to make it

                > perform as described in the standards document.

                > >

                > >

                > >

                > >   --Tim

                > >

                > >

                > >

                > >   From: ASCOM-Talk@yahoogroups.com

                [mailto:ASCOM-

                > Talk@yahoogroups.com] On Behalf Of billerwellm

                > >   Sent: 02 March 2008 07:51

                > >   To: ASCOM-Talk@yahoogroups.com

                > >   Subject: [ASCOM] Bit of help

                writing Focuser Driver using VB

                > >

                > >

                > >

                > >   Hi,

                > >

                > >   It's my first time writing a driver

                and my VB experience is very

                > little. I have built a focuser using a servo motor

                and have it

                > controlled via a slide bar GUI using VB (not ASCOM

                compliant). Please

                > see below:-

                > >

                > >   Option Explicit

                > >

                > >   Private Sub Form_Load()

                > >

                > >   'These are key properties in

                controlling

                > >   'scrolling behavior

                > >

                > >   VScroll1.SmallChange = 1 'how much

                to change value on arrow click

                > >   VScroll1.LargeChange = 15 'how much

                to change value on scroll

                > >   VScroll1.Min = 117 'minimum value

                (set to text box top)

                > >   VScroll1.Max = 195 'maximum value

                (set to text box height

                > >

                > >   VScroll1.Value = 157 'set vscroll

                mid start point

                > >   Text2(0).Text = VScroll1.Value

                > >

                > >     With MSComm1

                > >       'make sure

                the serial port is not open (by this program)

                > >       If .PortOpen

                Then .PortOpen = False

                > >       'set the

                active serial port

                > >       .CommPort =

                1

                > >       'set the

                badurate,parity,databits,stopbits for the connection

                > >       .Settings =

                "9600,N,8,1"

                > >       'set the

                DRT and RTS flags

                > >       .DTREnable

                = True

                > >       .RTSEnable

                = True

                > >       'enable the

                oncomm event for every reveived character

                > >       .RThreshold

                = 1

                > >       'disable

                the oncomm event for send characters

                > >       .SThreshold

                = 0

                > >       'open the

                serial port

                > >       .PortOpen =

                True

                > >     End With 'MSComm1

                > >

                > >   End Sub

                > >

                > >

                > >   Private Sub VScroll1_Change()

                > >

                > >    Text2(0).Text =

                VScroll1.Value ' provides reset slide bar value

                > >

                > >    With MSComm1

                > >       'make sure

                the serial port is open

                > >       If

                .PortOpen = False Then .PortOpen = True

                > >       'send the

                data (including a tailing carriage return as often

                > needed)

                > >       .Output =

                Chr$(1) ' Select which servo to drive

                > >       .Output =

                Chr$(VScroll1.Value)

                > >     End With 'MSComm1

                > >

                > >     VScroll1.Value = 157

                > >     Text2(0).Text =

                VScroll1.Value ' provides reset slide bar value

                > >

                > >   End Sub

                > >

                > >

                > >   Private Sub VScroll1_Scroll()

                > >     Text2(0).Text =

                VScroll1.Value ' provides reset slide bar value

                > >

                > >     With MSComm1

                > >       'make sure

                the serial port is open

                > >       If

                .PortOpen = False Then .PortOpen = True

                > >       'send the

                data (including a tailing carriage return as often

                > needed)

                > >       .Output =

                Chr$(1) ' Select which servo to drive

                > >       .Output =

                Chr$(VScroll1.Value)

                > >     End With 'MSComm1

                > >

                > >   End Sub

                > >

                > >

                > >   Basically a couple of values are

                sent to the PIC using the

                > `MSComm1.Output' command to tell the servo what to

                do via a com port.

                > >

                > >   I have downloaded and set up the

                focuser template from ASCOM but

                > I have no idea what code to put in the TODO areas.

                Say in the case of

                > the code below, am I right in assuming (please tell

                me if I'm wrong)

                > I just put a set value in place of the TODO sentence

                relating to my

                > focuser for what ever controlling software is

                wanting to speak to the

                > focuser? If so what should the code defining that

                value look like?

                > >

                > >       Public

                ReadOnly Property MaxStep() As Integer Implements

                > IFocuser.MaxStep

                > >           '

                TODO Replace this with your implementation

                > >          

                Get

                > >               

                Throw New PropertyNotImplementedException("MaxStep",

                > False)

                > >          

                End Get

                > >       End

                Property

                > >

                > >   Same with the next bit of code. I

                assume (once again please tell

                > me if I'm wrong) this TODO requires me to use a

                values that it sent

                > to my driver and move my focuser that amount. Is

                this where I would

                > use the 'MSComm1.Output' command to send the value

                to the PIC.

                > >

                > >       Public Sub

                Move(ByVal val As Integer) Implements IFocuser.Move

                > >          

                ' TODO Replace this with your implementation

                > >          

                Throw New MethodNotImplementedException("Move")

                > >       End Sub

                > >

                > >   The rest of the template is pretty

                much down the  same path. So

                > if I get an understanding of these 2 I should

                hopefully be able to

                > work out the rest. I have looked around for some

                completed focuser

                > code using the ASCOM template without any luck. If

                anyone can direct

                > me to some it would be much appreciated. Otherwise

                if someone could

                > please show me an example of what I could put in the

                TODO parts that

                > would be great also.

                > >

                > >   Thanks for taking to time to read

                my question.

                > >

                > >   Cheers,

                > >

                > >   Markus

                > >

                >

                >

                >

                >

                > For more information see http://ASCOM-Standards.org/.

                >

                > To unsubscribe from this group, send an email FROM

                THE ACCOUNT YOU USED

                > TO SUBSCRIBE(!) to:

                > ASCOM-Talk-unsubscribe@yahoogroups.com

                >

                >

                > Yahoo! Groups Links

                >

                > <*> To visit your group on the web, go to:

                >     http://groups.yahoo.com/group/ASCOM-Talk/

                >

                > <*> Your email settings:

                >     Individual Email |

                Traditional

                >

                > <*> To change settings online go to:

                >     http://groups.yahoo.com/group/ASCOM-Talk/join

                >     (Yahoo! ID required)

                >

                > <*> To change settings via email:

                >     mailto:ASCOM-Talk-digest@yahoogroups.com

                >     mailto:ASCOM-Talk-fullfeatured@yahoogroups.com

                >

                > <*> To unsubscribe from this group, send an

                email to:

                >     ASCOM-Talk-unsubscribe@yahoogroups.com

                >

                > <*> Your use of Yahoo! Groups is subject to:

                >     http://docs.yahoo.com/info/terms/

                >

              • peterjchance
                Thanks Tim, you are absolutely right of course, and I can now set up my parameters as required. Could I ask you for a little more help, in that I can t get the
                Message 7 of 16 , Mar 6, 2008
                • 0 Attachment
                  Thanks Tim, you are absolutely right of course, and I can now set up
                  my parameters as required.

                  Could I ask you for a little more help, in that I can't get the
                  focuser to connect. I have tried a variety of things without luck. If
                  I can get it to connect I think I will be able (hopefully) to manage
                  it from there.

                  If you are willing to help, what should happen in the following
                  routine:

                  Public Property Link() As Boolean Implements IFocuser.Link
                  ' TODO Replace this with your implementation
                  Get
                  Throw New PropertyNotImplementedException("Link", False)
                  End Get
                  Set(ByVal Value As Boolean)
                  Throw New PropertyNotImplementedException("Link", True)
                  End Set
                  End Property

                  And how do I ensure that that the routine is run when I click on
                  connect?

                  Hope you can help.

                  Regards

                  Peter



                  --- In ASCOM-Talk@yahoogroups.com, "Tim Long" <Tim@...> wrote:
                  >
                  > There isn't enough information to go on from the snippet you
                  posted, but
                  > it looks like you're trying to write to the interface, which cannot
                  work
                  > because interfaces are abstract definitions with no executable code
                  in
                  > them. If you used the template focuser project provided with
                  Platform 5,
                  > then you should have a bunch of methods and properties within a
                  #region
                  > called "IFocuser members". One of those properties is MaxStep,
                  defined
                  > as follows:
                  >
                  >
                  >
                  > Public ReadOnly Property MaxStep() As Integer Implements
                  > IFocuser.MaxStep
                  >
                  > ' TODO Replace this with your implementation
                  >
                  > Get
                  >
                  > Throw New
                  > PropertyNotImplementedException("MaxStep", False)
                  >
                  > End Get
                  >
                  > End Property
                  >
                  >
                  >
                  >
                  >
                  > You need to edit that code to simply return your MaxStep value. So
                  if
                  > your MaxStep was 5000, you might do something like:
                  >
                  >
                  >
                  > Public ReadOnly Property MaxStep() As Integer Implements
                  > IFocuser.MaxStep
                  >
                  > ' TODO Replace this with your implementation
                  >
                  > Get
                  >
                  > Return 5000
                  >
                  > End Get
                  >
                  > End Property
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  > Best regards,
                  >
                  >
                  >
                  > Tim Long <http://community.tigranetworks.co.uk/blogs/Tim_Long>
                  >
                  > Owner & Technology Consultant
                  >
                  > TiGra Networks
                  > <http://community.tigranetworks.co.uk/blogs/TiGraNetworks/>
                  >
                  > The Small Business IT Specialists
                  >
                  > 01443 208678 | www.tigranetworks.co.uk
                  <http://www.tigranetworks.co.uk>
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  > > -----Original Message-----
                  >
                  > > From: ASCOM-Talk@yahoogroups.com [mailto:ASCOM-
                  Talk@yahoogroups.com]
                  > On
                  >
                  > > Behalf Of peterjchance
                  >
                  > > Sent: 05 March 2008 00:14
                  >
                  > > To: ASCOM-Talk@yahoogroups.com
                  >
                  > > Subject: Re: [ASCOM] Bit of help writing Focuser Driver using VB
                  >
                  > >
                  >
                  > > I hope you guys don't mind me jumping in at this point but I am
                  in a
                  >
                  > > simliar situation to Marcus in that I also intend to use a pic
                  chip
                  >
                  > > to control a focuser and am having some trouble with the VB code
                  for
                  >
                  > > the simulator.
                  >
                  > >
                  >
                  > > I have no problem with the pic stuff and am quite comfortable with
                  >
                  > > VB6, but this is my first venture with vb.net (vb 2005).
                  >
                  > >
                  >
                  > > I have already used the simulator template to set up my
                  application
                  >
                  > > and I can see and select my focuser in the chooser when I run
                  MaxIm.
                  >
                  > > I have also been able to run the application in debug mode and can
                  >
                  > > step through the code.
                  >
                  > >
                  >
                  > > What I am having trouble with, and to be honest this is no doubt
                  >
                  > > purely my lack of knowledge with vb.net, is how to set a variable
                  >
                  > > such as MaxStep.
                  >
                  > >
                  >
                  > > MaxStep is read only and according to the books the only way to
                  set a
                  >
                  > > value for a read only property is to define it in the constructor.
                  >
                  > > The constructor appears to be at the top of the program, and
                  implies
                  >
                  > > that my code should be in the following routine:
                  >
                  > >
                  >
                  > > Public Sub New()
                  >
                  > >
                  >
                  > > IFocuser.MaxStep = 1000 ' My code
                  >
                  > >
                  >
                  > > ' TODO Implement your additional construction here
                  >
                  > > End Sub
                  >
                  > >
                  >
                  > > Whatever I do, however, and I have tried many things, the program
                  >
                  > > still gives an error saying that MaxStep is read only.
                  >
                  > >
                  >
                  > > Can anyone shed some light on this matter to get me on the right
                  >
                  > > track?
                  >
                  > >
                  >
                  > > Regards
                  >
                  > >
                  >
                  > > Peter
                  >
                  > >
                  >
                  > >
                  >
                  > > --- In ASCOM-Talk@yahoogroups.com, "Larry Weber" <larryweber@>
                  >
                  > > wrote:
                  >
                  > > >
                  >
                  > > > Markus,
                  >
                  > > >
                  >
                  > > > I think Tim makes a good point.
                  >
                  > > >
                  >
                  > > > One fun way to climb this learning curve is to take the VB
                  source
                  >
                  > > code for the Focuser Simulator and then run it in VB under debug
                  >
                  > > mode. For starters, I would put a breakpoint at the beginning of
                  >
                  > > each subroutine in the Focuser Class. Then get some program that
                  can
                  >
                  > > control ASCOM focusers such as MaxIm DL or FocusMax, and connect
                  one
                  >
                  > > of them to the Focuser Simulator. When you do this with the
                  Focuser
                  >
                  > > Simulator source code running under VB in debug mode, a focuser
                  >
                  > > operation that is initiated in MaxIm or FocusMax will talk to the
                  >
                  > > version of Focuser Simulator that you are running in debug mode.
                  Any
                  >
                  > > command initiated by MaxIm or FocusMax will hit one of the
                  >
                  > > breakpoints you have set. You can step through the source code,
                  >
                  > > examine the variables and see how it all works.
                  >
                  > > >
                  >
                  > > > Once you get through this exercise, you can make your own
                  version
                  >
                  > > of the Focuser Simulator and put in some of the code for your
                  >
                  > > focuser. Pick the Focuser class Move subroutine first and put in
                  >
                  > > some code that will cause your focuser to move. Maxim has a
                  feature
                  >
                  > > for manually moving the focuser under Telescope Control on the
                  >
                  > > Focuser tab. Or you could click the Jog button in FocusMax to do
                  >
                  > > manual control. Any way you do it, you will gain confidence and
                  >
                  > > learn a lot just by seeing your focuser move under the control of
                  >
                  > > either MaxIm or FocusMax.
                  >
                  > > >
                  >
                  > > > Larry
                  >
                  > > >
                  >
                  > > >
                  >
                  > > >
                  >
                  > > >
                  >
                  > > >
                  >
                  > > >
                  >
                  > > >
                  >
                  > > >
                  >
                  > > > ----- Original Message -----
                  >
                  > > > From: Tim Long
                  >
                  > > > To: ASCOM-Talk@yahoogroups.com
                  >
                  > > > Sent: Sunday, March 02, 2008 2:44 PM
                  >
                  > > > Subject: RE: [ASCOM] Bit of help writing Focuser Driver using
                  VB
                  >
                  > > >
                  >
                  > > >
                  >
                  > > >
                  >
                  > > > I think you really need to read through the ASCOM focuser
                  >
                  > > standard and get an understanding of what all the properties and
                  >
                  > > methods are supposed to do. You then have to add your own code to
                  >
                  > > each property and method that is applicable to your device to
                  make it
                  >
                  > > perform as described in the standards document.
                  >
                  > > >
                  >
                  > > >
                  >
                  > > >
                  >
                  > > > --Tim
                  >
                  > > >
                  >
                  > > >
                  >
                  > > >
                  >
                  > > > From: ASCOM-Talk@yahoogroups.com [mailto:ASCOM-
                  >
                  > > Talk@yahoogroups.com] On Behalf Of billerwellm
                  >
                  > > > Sent: 02 March 2008 07:51
                  >
                  > > > To: ASCOM-Talk@yahoogroups.com
                  >
                  > > > Subject: [ASCOM] Bit of help writing Focuser Driver using VB
                  >
                  > > >
                  >
                  > > >
                  >
                  > > >
                  >
                  > > > Hi,
                  >
                  > > >
                  >
                  > > > It's my first time writing a driver and my VB experience is
                  very
                  >
                  > > little. I have built a focuser using a servo motor and have it
                  >
                  > > controlled via a slide bar GUI using VB (not ASCOM compliant).
                  Please
                  >
                  > > see below:-
                  >
                  > > >
                  >
                  > > > Option Explicit
                  >
                  > > >
                  >
                  > > > Private Sub Form_Load()
                  >
                  > > >
                  >
                  > > > 'These are key properties in controlling
                  >
                  > > > 'scrolling behavior
                  >
                  > > >
                  >
                  > > > VScroll1.SmallChange = 1 'how much to change value on arrow
                  click
                  >
                  > > > VScroll1.LargeChange = 15 'how much to change value on scroll
                  >
                  > > > VScroll1.Min = 117 'minimum value (set to text box top)
                  >
                  > > > VScroll1.Max = 195 'maximum value (set to text box height
                  >
                  > > >
                  >
                  > > > VScroll1.Value = 157 'set vscroll mid start point
                  >
                  > > > Text2(0).Text = VScroll1.Value
                  >
                  > > >
                  >
                  > > > With MSComm1
                  >
                  > > > 'make sure the serial port is not open (by this program)
                  >
                  > > > If .PortOpen Then .PortOpen = False
                  >
                  > > > 'set the active serial port
                  >
                  > > > .CommPort = 1
                  >
                  > > > 'set the badurate,parity,databits,stopbits for the
                  connection
                  >
                  > > > .Settings = "9600,N,8,1"
                  >
                  > > > 'set the DRT and RTS flags
                  >
                  > > > .DTREnable = True
                  >
                  > > > .RTSEnable = True
                  >
                  > > > 'enable the oncomm event for every reveived character
                  >
                  > > > .RThreshold = 1
                  >
                  > > > 'disable the oncomm event for send characters
                  >
                  > > > .SThreshold = 0
                  >
                  > > > 'open the serial port
                  >
                  > > > .PortOpen = True
                  >
                  > > > End With 'MSComm1
                  >
                  > > >
                  >
                  > > > End Sub
                  >
                  > > >
                  >
                  > > >
                  >
                  > > > Private Sub VScroll1_Change()
                  >
                  > > >
                  >
                  > > > Text2(0).Text = VScroll1.Value ' provides reset slide bar
                  value
                  >
                  > > >
                  >
                  > > > With MSComm1
                  >
                  > > > 'make sure the serial port is open
                  >
                  > > > If .PortOpen = False Then .PortOpen = True
                  >
                  > > > 'send the data (including a tailing carriage return as
                  often
                  >
                  > > needed)
                  >
                  > > > .Output = Chr$(1) ' Select which servo to drive
                  >
                  > > > .Output = Chr$(VScroll1.Value)
                  >
                  > > > End With 'MSComm1
                  >
                  > > >
                  >
                  > > > VScroll1.Value = 157
                  >
                  > > > Text2(0).Text = VScroll1.Value ' provides reset slide bar
                  value
                  >
                  > > >
                  >
                  > > > End Sub
                  >
                  > > >
                  >
                  > > >
                  >
                  > > > Private Sub VScroll1_Scroll()
                  >
                  > > > Text2(0).Text = VScroll1.Value ' provides reset slide bar
                  value
                  >
                  > > >
                  >
                  > > > With MSComm1
                  >
                  > > > 'make sure the serial port is open
                  >
                  > > > If .PortOpen = False Then .PortOpen = True
                  >
                  > > > 'send the data (including a tailing carriage return as
                  often
                  >
                  > > needed)
                  >
                  > > > .Output = Chr$(1) ' Select which servo to drive
                  >
                  > > > .Output = Chr$(VScroll1.Value)
                  >
                  > > > End With 'MSComm1
                  >
                  > > >
                  >
                  > > > End Sub
                  >
                  > > >
                  >
                  > > >
                  >
                  > > > Basically a couple of values are sent to the PIC using the
                  >
                  > > `MSComm1.Output' command to tell the servo what to do via a com
                  port.
                  >
                  > > >
                  >
                  > > > I have downloaded and set up the focuser template from ASCOM
                  but
                  >
                  > > I have no idea what code to put in the TODO areas. Say in the
                  case of
                  >
                  > > the code below, am I right in assuming (please tell me if I'm
                  wrong)
                  >
                  > > I just put a set value in place of the TODO sentence relating to
                  my
                  >
                  > > focuser for what ever controlling software is wanting to speak to
                  the
                  >
                  > > focuser? If so what should the code defining that value look like?
                  >
                  > > >
                  >
                  > > > Public ReadOnly Property MaxStep() As Integer Implements
                  >
                  > > IFocuser.MaxStep
                  >
                  > > > ' TODO Replace this with your implementation
                  >
                  > > > Get
                  >
                  > > > Throw New PropertyNotImplementedException
                  ("MaxStep",
                  >
                  > > False)
                  >
                  > > > End Get
                  >
                  > > > End Property
                  >
                  > > >
                  >
                  > > > Same with the next bit of code. I assume (once again please
                  tell
                  >
                  > > me if I'm wrong) this TODO requires me to use a values that it
                  sent
                  >
                  > > to my driver and move my focuser that amount. Is this where I
                  would
                  >
                  > > use the 'MSComm1.Output' command to send the value to the PIC.
                  >
                  > > >
                  >
                  > > > Public Sub Move(ByVal val As Integer) Implements
                  IFocuser.Move
                  >
                  > > > ' TODO Replace this with your implementation
                  >
                  > > > Throw New MethodNotImplementedException("Move")
                  >
                  > > > End Sub
                  >
                  > > >
                  >
                  > > > The rest of the template is pretty much down the same path.
                  So
                  >
                  > > if I get an understanding of these 2 I should hopefully be able to
                  >
                  > > work out the rest. I have looked around for some completed focuser
                  >
                  > > code using the ASCOM template without any luck. If anyone can
                  direct
                  >
                  > > me to some it would be much appreciated. Otherwise if someone
                  could
                  >
                  > > please show me an example of what I could put in the TODO parts
                  that
                  >
                  > > would be great also.
                  >
                  > > >
                  >
                  > > > Thanks for taking to time to read my question.
                  >
                  > > >
                  >
                  > > > Cheers,
                  >
                  > > >
                  >
                  > > > Markus
                  >
                  > > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > > For more information see http://ASCOM-Standards.org/.
                  >
                  > >
                  >
                  > > To unsubscribe from this group, send an email FROM THE ACCOUNT YOU
                  > USED
                  >
                  > > TO SUBSCRIBE(!) to:
                  >
                  > > ASCOM-Talk-unsubscribe@yahoogroups.com
                  >
                  > >
                  >
                  > >
                  >
                  > > Yahoo! Groups Links
                  >
                  > >
                  >
                  > > http://groups.yahoo.com/group/ASCOM-Talk/
                  >
                  > >
                  >
                  > > Individual Email | Traditional
                  >
                  > >
                  >
                  > > http://groups.yahoo.com/group/ASCOM-Talk/join
                  >
                  > > (Yahoo! ID required)
                  >
                  > >
                  >
                  > > mailto:ASCOM-Talk-digest@yahoogroups.com
                  >
                  > > mailto:ASCOM-Talk-fullfeatured@yahoogroups.com
                  >
                  > >
                  >
                  > > ASCOM-Talk-unsubscribe@yahoogroups.com
                  >
                  > >
                  >
                  > > http://docs.yahoo.com/info/terms/
                  >
                  > >
                  >
                • Tim Long
                  To answer the second question first, set a breakpoint on the Set part of the property. Sometimes it can be tricky to debug ASCOM drivers because they are
                  Message 8 of 16 , Mar 6, 2008
                  • 0 Attachment

                    To answer the second question first, set a breakpoint on the Set part of the property. Sometimes it can be tricky to debug ASCOM drivers because they are loaded into an external application. The way to do that is to start the application (POTH, perhaps) and then in the Visual Studio Debug menu, select Attach to Process... (carry on my example, you would then browse to POTH.exe and attach to it - then when you hit Connect in POTH, you should hit your breakpoint and be able to single-step through your code).

                     

                    Now for the first question. I'm afraid this code segment may not make much sense to you because it is in C# and not VB. But this is how I set up my serial port...

                     

                    using System.IO.Ports;

                    //... lots of code deleted ...

                           private SerialPort port = null;   // Deliberately uninitialised until Open() called.

                          //... lots of code deleted ...

                            /// <summary>

                            /// Go online or offline or query whether the serial port is online.

                            /// Transitioning from Offline to Online resets all communications parameters.

                            /// Going online when the port is already online is allowed but ignored.

                            /// Any exceptions that occur are considered fatal and will propagate up to the ASCOM layer.

                            /// </summary>

                            public void Open()

                            {

                                Diagnostics.TraceInfo("Go Online requested");

                                if (port != null)

                                {

                                    Diagnostics.TraceError("Disposing old port instance.");

                                               port.Dispose();

                                }

                                else

                                {

                                    Diagnostics.TraceVerbose("Configuring serial I/O parameters.");

                                    try

                                    {

                                                port = new SerialPort();

                                               //port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);

                                               port.ErrorReceived += new SerialErrorReceivedEventHandler(port_ErrorReceived);

                                        // The serial parameters are all set in the App.config file so they can be changed in-the-field.

                                        port.PortName = Properties.Settings.Default.SerialPortName;

                                        port.BaudRate = Properties.Settings.Default.SerialSpeed;

                                        port.DataBits = Properties.Settings.Default.SerialDataBits;

                                        port.DtrEnable = Properties.Settings.Default.SerialDTREnable;

                                        //port.Encoding = Encoding.ASCII;

                                                      //port.Encoding = Encoding.UTF8;

                                                       port.Encoding = Encoding.Default;

                                        port.Handshake = Properties.Settings.Default.SerialHandshake;

                                        port.NewLine = Protocol.EndCmd;

                                        port.Parity = Properties.Settings.Default.SerialParity;

                                        //port.ParityReplace = Protocol.Newline;  //TODO: Investigate the effect of doing this!

                                        port.PortName = Properties.Settings.Default.SerialPortName;

                                        port.ReadBufferSize = Properties.Settings.Default.SerialReadBufferSize;

                                        port.ReadTimeout = Properties.Settings.Default.SerialReadTimeoutMs;

                                        port.ReceivedBytesThreshold = Properties.Settings.Default.SerialReceivedBytesThreshold;

                                        port.RtsEnable = Properties.Settings.Default.SerialRTSEnable;

                                        port.StopBits = Properties.Settings.Default.SerialStopBits;

                                        port.WriteBufferSize = Properties.Settings.Default.SerialWriteBufferSize;

                                        port.WriteTimeout = Properties.Settings.Default.SerialWriteTimeoutMs;

                                        port.Open();

                                        if (!port.IsOpen)

                                        {

                                            throw new ApplicationException("Serial port Open() succeeded but then reported that it was not open.");

                                        }

                                                      // Sometimes when the port connects there is garbage in the input buffer.

                                                      // We'll try to flush it out here.

                                                      port.DiscardOutBuffer();

                                                      port.ReadExisting();

                                                      port.DiscardInBuffer();

                           //... other initialization not relevant to this example.

                     

                    Note that I store all of my serial parameters in the Application.settings file, with default values set there rather than hard-wired into the code. In C# the values are accessed through Properties.Settings.xxx – I think in VB you would use My.Settings.xxx

                     

                    --Tim

                     

                     

                    > -----Original Message-----

                    > From: ASCOM-Talk@yahoogroups.com

                    [mailto:ASCOM-Talk@yahoogroups.com] On

                    > Behalf Of peterjchance

                    > Sent: 06 March 2008 10:24

                    > To: ASCOM-Talk@yahoogroups.com

                    > Subject: Re: [ASCOM] Bit of help

                    writing Focuser Driver using VB

                    >

                    > Thanks Tim, you are absolutely right of course, and

                    I can now set up

                    > my parameters as required.

                    >

                    > Could I ask you for a little more help, in that I

                    can't get the

                    > focuser to connect. I have tried a variety of things

                    without luck. If

                    > I can get it to connect I think I will be able

                    (hopefully) to manage

                    > it from there.

                    >

                    > If you are willing to help, what should happen in

                    the following

                    > routine:

                    >

                    >     Public Property Link() As

                    Boolean Implements IFocuser.Link

                    >         '

                    TODO Replace this with your implementation

                    >         Get

                    >             Throw

                    New PropertyNotImplementedException("Link", False)

                    >         End

                    Get

                    >         Set(ByVal

                    Value As Boolean)

                    >             Throw

                    New PropertyNotImplementedException("Link", True)

                    >         End

                    Set

                    >     End Property

                    >

                    > And how do I ensure that that the routine is run

                    when I click on

                    > connect?

                    >

                    > Hope you can help.

                    >

                    > Regards

                    >

                    > Peter

                    >

                    >

                    >

                    > --- In ASCOM-Talk@yahoogroups.com, "Tim

                    Long" <Tim@...> wrote:

                    > >

                    > > There isn't enough information to go on from

                    the snippet you

                    > posted, but

                    > > it looks like you're trying to write to the

                    interface, which cannot

                    > work

                    > > because interfaces are abstract definitions

                    with no executable code

                    > in

                    > > them. If you used the template focuser project

                    provided with

                    > Platform 5,

                    > > then you should have a bunch of methods and

                    properties within a

                    > #region

                    > > called "IFocuser members". One of

                    those properties is MaxStep,

                    > defined

                    > > as follows:

                    > >

                    > >

                    > >

                    > >       

                    Public ReadOnly Property MaxStep() As Integer Implements

                    > > IFocuser.MaxStep

                    > >

                    > >              

                    ' TODO Replace this with your implementation

                    > >

                    > >              

                    Get

                    > >

                    > >                      

                    Throw New

                    > > PropertyNotImplementedException("MaxStep",

                    False)

                    > >

                    > >              

                    End Get

                    > >

                    > >        End

                    Property

                    > >

                    > >

                    > >

                    > >

                    > >

                    > > You need to edit that code to simply return

                    your MaxStep value. So

                    > if

                    > > your MaxStep was 5000, you might do something

                    like:

                    > >

                    > >

                    > >

                    > >       

                    Public ReadOnly Property MaxStep() As Integer Implements

                    > > IFocuser.MaxStep

                    > >

                    > >              

                    ' TODO Replace this with your implementation

                    > >

                    > >              

                    Get

                    > >

                    > >                     

                    Return 5000

                    > >

                    > >              

                    End Get

                    > >

                    > >        End

                    Property

                    > >

                    > >

                    > >

                    > >

                    > >

                    > >

                    > >

                    > > Best regards,

                    > >

                    > >

                    > >

                    > > Tim Long

                    <http://community.tigranetworks.co.uk/blogs/Tim_Long>

                    > >

                    > > Owner & Technology Consultant

                    > >

                    > > TiGra Networks

                    > >

                    <http://community.tigranetworks.co.uk/blogs/TiGraNetworks/>

                    > >

                    > > The Small Business IT Specialists

                    > >

                    > > 01443 208678 | www.tigranetworks.co.uk

                    > <http://www.tigranetworks.co.uk>

                    > >

                    > >

                    > >

                    > >

                    > >

                    > >

                    > >

                    > >

                    > >

                    > > > -----Original Message-----

                    > >

                    > > > From: ASCOM-Talk@yahoogroups.com

                    [mailto:ASCOM-

                    > Talk@yahoogroups.com]

                    > > On

                    > >

                    > > > Behalf Of peterjchance

                    > >

                    > > > Sent: 05 March 2008 00:14

                    > >

                    > > > To: ASCOM-Talk@yahoogroups.com

                    > >

                    > > > Subject: Re: [ASCOM] Bit of help writing

                    Focuser Driver using VB

                    > >

                    > > >

                    > >

                    > > > I hope you guys don't mind me jumping in

                    at this point but I am

                    > in a

                    > >

                    > > > simliar situation to Marcus in that I also

                    intend to use a pic

                    > chip

                    > >

                    > > > to control a focuser and am having some

                    trouble with the VB code

                    > for

                    > >

                    > > > the simulator.

                    > >

                    > > >

                    > >

                    > > > I have no problem with the pic stuff and

                    am quite comfortable with

                    > >

                    > > > VB6, but this is my first venture with

                    vb.net (vb 2005).

                    > >

                    > > >

                    > >

                    > > > I have already used the simulator template

                    to set up my

                    > application

                    > >

                    > > > and I can see and select my focuser in the

                    chooser when I run

                    > MaxIm.

                    > >

                    > > > I have also been able to run the

                    application in debug mode and can

                    > >

                    > > > step through the code.

                    > >

                    > > >

                    > >

                    > > > What I am having trouble with, and to be

                    honest this is no doubt

                    > >

                    > > > purely my lack of knowledge with vb.net,

                    is how to set a variable

                    > >

                    > > > such as MaxStep.

                    > >

                    > > >

                    > >

                    > > > MaxStep is read only and according to the

                    books the only way to

                    > set a

                    > >

                    > > > value for a read only property is to

                    define it in the constructor.

                    > >

                    > > > The constructor appears to be at the top

                    of the program, and

                    > implies

                    > >

                    > > > that my code should be in the following

                    routine:

                    > >

                    > > >

                    > >

                    > > >     Public Sub New()

                    > >

                    > > >

                    > >

                    > > >         IFocuser.MaxStep = 1000 '

                    My code

                    > >

                    > > >

                    > >

                    > > >         ' TODO Implement your

                    additional construction here

                    > >

                    > > >     End Sub

                    > >

                    > > >

                    > >

                    > > > Whatever I do, however, and I have tried

                    many things, the program

                    > >

                    > > > still gives an error saying that MaxStep

                    is read only.

                    > >

                    > > >

                    > >

                    > > > Can anyone shed some light on this matter

                    to get me on the right

                    > >

                    > > > track?

                    > >

                    > > >

                    > >

                    > > > Regards

                    > >

                    > > >

                    > >

                    > > > Peter

                    > >

                    > > >

                    > >

                    > > >

                    > >

                    > > > --- In ASCOM-Talk@yahoogroups.com,

                    "Larry Weber" <larryweber@>

                    > >

                    > > > wrote:

                    > >

                    > > > >

                    > >

                    > > > > Markus,

                    > >

                    > > > >

                    > >

                    > > > > I think Tim makes a good point.

                    > >

                    > > > >

                    > >

                    > > > > One fun way to climb this learning

                    curve is to take the VB

                    > source

                    > >

                    > > > code for the Focuser Simulator and then

                    run it in VB under debug

                    > >

                    > > > mode.  For starters, I would put a

                    breakpoint at the beginning of

                    > >

                    > > > each subroutine in the Focuser Class. 

                    Then get some program that

                    > can

                    > >

                    > > > control ASCOM focusers such as MaxIm DL or

                    FocusMax, and connect

                    > one

                    > >

                    > > > of them to the Focuser Simulator. 

                    When you do this with the

                    > Focuser

                    > >

                    > > > Simulator source code running under VB in

                    debug mode, a focuser

                    > >

                    > > > operation that is initiated in MaxIm or

                    FocusMax will talk to the

                    > >

                    > > > version of Focuser Simulator that you are

                    running in debug mode.

                    > Any

                    > >

                    > > > command initiated by MaxIm or FocusMax

                    will hit one of the

                    > >

                    > > > breakpoints you have set.  You can

                    step through the source code,

                    > >

                    > > > examine the variables and see how it all

                    works.

                    > >

                    > > > >

                    > >

                    > > > > Once you get through this exercise,

                    you can make your own

                    > version

                    > >

                    > > > of the Focuser Simulator and put in some

                    of the code for your

                    > >

                    > > > focuser.  Pick the Focuser class Move

                    subroutine first and put in

                    > >

                    > > > some code that will cause your focuser to

                    move.  Maxim has a

                    > feature

                    > >

                    > > > for manually moving the focuser under

                    Telescope Control on the

                    > >

                    > > > Focuser tab.  Or you could click the

                    Jog button in FocusMax to do

                    > >

                    > > > manual control.  Any way you do it,

                    you will gain confidence and

                    > >

                    > > > learn a lot just by seeing your focuser

                    move under the control of

                    > >

                    > > > either MaxIm or FocusMax.

                    > >

                    > > > >

                    > >

                    > > > > Larry

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >   ----- Original Message

                    -----

                    > >

                    > > > >   From: Tim Long

                    > >

                    > > > >   To:

                    ASCOM-Talk@yahoogroups.com

                    > >

                    > > > >   Sent: Sunday, March 02,

                    2008 2:44 PM

                    > >

                    > > > >   Subject: RE: [ASCOM] Bit

                    of help writing Focuser Driver using

                    > VB

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >   I think you really need

                    to read through the ASCOM focuser

                    > >

                    > > > standard and get an understanding of what

                    all the properties and

                    > >

                    > > > methods are supposed to do. You then have

                    to add your own code to

                    > >

                    > > > each property and method that is

                    applicable to your device to

                    > make it

                    > >

                    > > > perform as described in the standards

                    document.

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >   --Tim

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >   From:

                    ASCOM-Talk@yahoogroups.com [mailto:ASCOM-

                    > >

                    > > > Talk@yahoogroups.com] On Behalf Of

                    billerwellm

                    > >

                    > > > >   Sent: 02 March 2008 07:51

                    > >

                    > > > >   To:

                    ASCOM-Talk@yahoogroups.com

                    > >

                    > > > >   Subject: [ASCOM] Bit of

                    help writing Focuser Driver using VB

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >

                    > >

                    > > > >   Hi,

                    > >

                    > > > >

                    > >

                    > > > >   It's my first time

                    writing a driver and my VB experience is

                    > very

                    > >

                    > > > little. I have built a focuser using a

                    servo motor and have it

                    > >

                    > > > controlled via a slide bar GUI using VB

                    (not ASCOM compliant).

                    > Please

                    > >

                    > > > see below:-

                    > >

                    > > > >

                    > >

                    > > > >   Option Explicit

                    > >

                    > > > >

                    > >

                    > > > >   Private Sub Form_Load()

                    > >

                    > > > >

                    > >

                    > > > >   'These are key properties

                    in controlling

                    > >

                    > > > >   'scrolling behavior

                    > >

                    > > > >

                    > >

                    > > > >   VScroll1.SmallChange = 1

                    'how much to change value on arrow

                    > click

                    > >

                    > > > >   VScroll1.LargeChange = 15

                    'how much to change value on scroll

                    > >

                    > > > >   VScroll1.Min = 117

                    'minimum value (set to text box top)

                    > >

                    > > > >   VScroll1.Max = 195

                    'maximum value (set to text box height

                    > >

                    > > > >

                    > >

                    > > > >   VScroll1.Value = 157 'set

                    vscroll mid start point

                    > >

                    > > > >   Text2(0).Text =

                    VScroll1.Value

                    > >

                    > > > >

                    > >

                    > > > >     With MSComm1

                    > >

                    > > > >      

                    'make sure the serial port is not open (by this program)

                    > >

                    > > > >      

                    If .PortOpen Then .PortOpen = False

                    > >

                    > > > >      

                    'set the active serial port

                    > >

                    > > > >      

                    .CommPort = 1

                    > >

                    > > > >      

                    'set the badurate,parity,databits,stopbits for the

                    > connection

                    > >

                    > > > >      

                    .Settings = "9600,N,8,1"

                    > >

                    > > > >      

                    'set the DRT and RTS flags

                    > >

                    > > > >      

                    .DTREnable = True

                    > >

                    > > > >      

                    .RTSEnable = True

                    > >

                    > > > >      

                    'enable the oncomm event for every reveived character

                    > >

                    > > > >      

                    .RThreshold = 1

                    > >

                    > > > >      

                    'disable the oncomm event for send characters

                    > >

                    > > > >      

                    .SThreshold = 0

                    > >

                    > > > >      

                    'open the serial port

                    > >

                    > > > >      

                    .PortOpen = True

                    > >

                    > > > >     End With

                    'MSComm1

                    > >

                    > > > >

                    > >

                    > > > >   End Sub

                    > >

                    > > > >

                    (Message over 64 KB, truncated)
                  • peterjchance
                    Hi Tim I think you believe I am further ahead that I actually am.. What I am doing at the moment is to make my own version of a simulator so that I can get to
                    Message 9 of 16 , Mar 7, 2008
                    • 0 Attachment
                      Hi Tim

                      I think you believe I am further ahead that I actually am..

                      What I am doing at the moment is to make my own version of a
                      simulator so that I can get to grips with the program. Once I have
                      done that I will move on to the real thing.

                      The question I asked, therefore, was how I should connect to the
                      simulator, not a real live focuser.

                      I have now managed to connect but don't believe I have done what is
                      really required.

                      What I have done is:

                      Public Sub New()
                      Link = True
                      End Sub

                      #Region "ASCOM Registration"


                      Public Property Link() As Boolean Implements IFocuser.Link
                      Get
                      Return True
                      'Throw New PropertyNotImplementedException("Link", False)
                      End Get
                      Set(ByVal Value As Boolean)
                      'Throw New PropertyNotImplementedException("Link", True)
                      End Set
                      End Property

                      This is the only way I could get it to link, but as I said it's not
                      right. I had to comment out all action in the Set to get it to
                      connect as I didn't know what to do there, and I don't think it will
                      dis-connect.

                      If you could throw some light on what the Set part of the routine is
                      for it would be a great help.

                      I will keep your last message for future use, as I will have to
                      tackle that problem later.

                      Thanks for you help, it's much appreciated.

                      Peter

                      --- In ASCOM-Talk@yahoogroups.com, "Tim Long" <Tim@...> wrote:
                      >
                      > To answer the second question first, set a breakpoint on the Set
                      part of
                      > the property. Sometimes it can be tricky to debug ASCOM drivers
                      because
                      > they are loaded into an external application. The way to do that is
                      to
                      > start the application (POTH, perhaps) and then in the Visual Studio
                      > Debug menu, select Attach to Process... (carry on my example, you
                      would
                      > then browse to POTH.exe and attach to it - then when you hit
                      Connect in
                      > POTH, you should hit your breakpoint and be able to single-step
                      through
                      > your code).
                      >
                      >
                      >
                      > Now for the first question. I'm afraid this code segment may not
                      make
                      > much sense to you because it is in C# and not VB. But this is how I
                      set
                      > up my serial port...
                      >
                      >
                      >
                      > using System.IO.Ports;
                      >
                      > //... lots of code deleted ...
                      >
                      > private SerialPort port = null; // Deliberately
                      uninitialised
                      > until Open() called.
                      >
                      > //... lots of code deleted ...
                      >
                      > /// <summary>
                      >
                      > /// Go online or offline or query whether the serial port is
                      > online.
                      >
                      > /// Transitioning from Offline to Online resets all
                      > communications parameters.
                      >
                      > /// Going online when the port is already online is allowed
                      but
                      > ignored.
                      >
                      > /// Any exceptions that occur are considered fatal and will
                      > propagate up to the ASCOM layer.
                      >
                      > /// </summary>
                      >
                      > public void Open()
                      >
                      > {
                      >
                      > Diagnostics.TraceInfo("Go Online requested");
                      >
                      > if (port != null)
                      >
                      > {
                      >
                      > Diagnostics.TraceError("Disposing old port
                      instance.");
                      >
                      > port.Dispose();
                      >
                      > }
                      >
                      > else
                      >
                      > {
                      >
                      > Diagnostics.TraceVerbose("Configuring serial I/O
                      > parameters.");
                      >
                      > try
                      >
                      > {
                      >
                      > port = new SerialPort();
                      >
                      > //port.DataReceived += new
                      > SerialDataReceivedEventHandler(port_DataReceived);
                      >
                      > port.ErrorReceived += new
                      > SerialErrorReceivedEventHandler(port_ErrorReceived);
                      >
                      > // The serial parameters are all set in the
                      > App.config file so they can be changed in-the-field.
                      >
                      > port.PortName =
                      > Properties.Settings.Default.SerialPortName;
                      >
                      > port.BaudRate =
                      > Properties.Settings.Default.SerialSpeed;
                      >
                      > port.DataBits =
                      > Properties.Settings.Default.SerialDataBits;
                      >
                      > port.DtrEnable =
                      > Properties.Settings.Default.SerialDTREnable;
                      >
                      > //port.Encoding = Encoding.ASCII;
                      >
                      > //port.Encoding = Encoding.UTF8;
                      >
                      > port.Encoding = Encoding.Default;
                      >
                      > port.Handshake =
                      > Properties.Settings.Default.SerialHandshake;
                      >
                      > port.NewLine = Protocol.EndCmd;
                      >
                      > port.Parity =
                      > Properties.Settings.Default.SerialParity;
                      >
                      > //port.ParityReplace =
                      Protocol.Newline; //TODO:
                      > Investigate the effect of doing this!
                      >
                      > port.PortName =
                      > Properties.Settings.Default.SerialPortName;
                      >
                      > port.ReadBufferSize =
                      > Properties.Settings.Default.SerialReadBufferSize;
                      >
                      > port.ReadTimeout =
                      > Properties.Settings.Default.SerialReadTimeoutMs;
                      >
                      > port.ReceivedBytesThreshold =
                      > Properties.Settings.Default.SerialReceivedBytesThreshold;
                      >
                      > port.RtsEnable =
                      > Properties.Settings.Default.SerialRTSEnable;
                      >
                      > port.StopBits =
                      > Properties.Settings.Default.SerialStopBits;
                      >
                      > port.WriteBufferSize =
                      > Properties.Settings.Default.SerialWriteBufferSize;
                      >
                      > port.WriteTimeout =
                      > Properties.Settings.Default.SerialWriteTimeoutMs;
                      >
                      > port.Open();
                      >
                      > if (!port.IsOpen)
                      >
                      > {
                      >
                      > throw new ApplicationException("Serial port
                      > Open() succeeded but then reported that it was not open.");
                      >
                      > }
                      >
                      > // Sometimes when the port
                      connects
                      > there is garbage in the input buffer.
                      >
                      > // We'll try to flush it out here.
                      >
                      > port.DiscardOutBuffer();
                      >
                      > port.ReadExisting();
                      >
                      > port.DiscardInBuffer();
                      >
                      > //... other initialization not relevant to this example.
                      >
                      >
                      >
                      > Note that I store all of my serial parameters in the
                      > Application.settings file, with default values set there rather than
                      > hard-wired into the code. In C# the values are accessed through
                      > Properties.Settings.xxx - I think in VB you would use
                      My.Settings.xxx
                      >
                      >
                      >
                      > --Tim
                      >
                      >
                      >
                      >
                      >
                      > > -----Original Message-----
                      >
                      > > From: ASCOM-Talk@yahoogroups.com [mailto:ASCOM-
                      Talk@yahoogroups.com]
                      > On
                      >
                      > > Behalf Of peterjchance
                      >
                      > > Sent: 06 March 2008 10:24
                      >
                      > > To: ASCOM-Talk@yahoogroups.com
                      >
                      > > Subject: Re: [ASCOM] Bit of help writing Focuser Driver using VB
                      >
                      > >
                      >
                      > > Thanks Tim, you are absolutely right of course, and I can now set
                      up
                      >
                      > > my parameters as required.
                      >
                      > >
                      >
                      > > Could I ask you for a little more help, in that I can't get the
                      >
                      > > focuser to connect. I have tried a variety of things without
                      luck. If
                      >
                      > > I can get it to connect I think I will be able (hopefully) to
                      manage
                      >
                      > > it from there.
                      >
                      > >
                      >
                      > > If you are willing to help, what should happen in the following
                      >
                      > > routine:
                      >
                      > >
                      >
                      > > Public Property Link() As Boolean Implements IFocuser.Link
                      >
                      > > ' TODO Replace this with your implementation
                      >
                      > > Get
                      >
                      > > Throw New PropertyNotImplementedException("Link",
                      False)
                      >
                      > > End Get
                      >
                      > > Set(ByVal Value As Boolean)
                      >
                      > > Throw New PropertyNotImplementedException("Link",
                      True)
                      >
                      > > End Set
                      >
                      > > End Property
                      >
                      > >
                      >
                      > > And how do I ensure that that the routine is run when I click on
                      >
                      > > connect?
                      >
                      > >
                      >
                      > > Hope you can help.
                      >
                      > >
                      >
                      > > Regards
                      >
                      > >
                      >
                      > > Peter
                      >
                      > >
                      >
                      > >
                      >
                      > >
                      >
                      > > --- In ASCOM-Talk@yahoogroups.com, "Tim Long" <Tim@> wrote:
                      >
                      > > >
                      >
                      > > > There isn't enough information to go on from the snippet you
                      >
                      > > posted, but
                      >
                      > > > it looks like you're trying to write to the interface, which
                      cannot
                      >
                      > > work
                      >
                      > > > because interfaces are abstract definitions with no executable
                      code
                      >
                      > > in
                      >
                      > > > them. If you used the template focuser project provided with
                      >
                      > > Platform 5,
                      >
                      > > > then you should have a bunch of methods and properties within a
                      >
                      > > #region
                      >
                      > > > called "IFocuser members". One of those properties is MaxStep,
                      >
                      > > defined
                      >
                      > > > as follows:
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > > Public ReadOnly Property MaxStep() As Integer Implements
                      >
                      > > > IFocuser.MaxStep
                      >
                      > > >
                      >
                      > > > ' TODO Replace this with your implementation
                      >
                      > > >
                      >
                      > > > Get
                      >
                      > > >
                      >
                      > > > Throw New
                      >
                      > > > PropertyNotImplementedException("MaxStep", False)
                      >
                      > > >
                      >
                      > > > End Get
                      >
                      > > >
                      >
                      > > > End Property
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > > You need to edit that code to simply return your MaxStep value.
                      So
                      >
                      > > if
                      >
                      > > > your MaxStep was 5000, you might do something like:
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > > Public ReadOnly Property MaxStep() As Integer Implements
                      >
                      > > > IFocuser.MaxStep
                      >
                      > > >
                      >
                      > > > ' TODO Replace this with your implementation
                      >
                      > > >
                      >
                      > > > Get
                      >
                      > > >
                      >
                      > > > Return 5000
                      >
                      > > >
                      >
                      > > > End Get
                      >
                      > > >
                      >
                      > > > End Property
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > > Best regards,
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > > Tim Long <http://community.tigranetworks.co.uk/blogs/Tim_Long>
                      >
                      > > >
                      >
                      > > > Owner & Technology Consultant
                      >
                      > > >
                      >
                      > > > TiGra Networks
                      >
                      > > > <http://community.tigranetworks.co.uk/blogs/TiGraNetworks/>
                      >
                      > > >
                      >
                      > > > The Small Business IT Specialists
                      >
                      > > >
                      >
                      > > > 01443 208678 | www.tigranetworks.co.uk
                      >
                      > > <http://www.tigranetworks.co.uk>
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > >
                      >
                      > > > > -----Original Message-----
                      >
                      > > >
                      >
                      > > > > From: ASCOM-Talk@yahoogroups.com [mailto:ASCOM-
                      >
                      > > Talk@yahoogroups.com]
                      >
                      > > > On
                      >
                      > > >
                      >
                      > > > > Behalf Of peterjchance
                      >
                      > > >
                      >
                      > > > > Sent: 05 March 2008 00:14
                      >
                      > > >
                      >
                      > > > > To: ASCOM-Talk@yahoogroups.com
                      >
                      > > >
                      >
                      > > > > Subject: Re: [ASCOM] Bit of help writing Focuser Driver using
                      VB
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > I hope you guys don't mind me jumping in at this point but I
                      am
                      >
                      > > in a
                      >
                      > > >
                      >
                      > > > > simliar situation to Marcus in that I also intend to use a pic
                      >
                      > > chip
                      >
                      > > >
                      >
                      > > > > to control a focuser and am having some trouble with the VB
                      code
                      >
                      > > for
                      >
                      > > >
                      >
                      > > > > the simulator.
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > I have no problem with the pic stuff and am quite comfortable
                      with
                      >
                      > > >
                      >
                      > > > > VB6, but this is my first venture with vb.net (vb 2005).
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > I have already used the simulator template to set up my
                      >
                      > > application
                      >
                      > > >
                      >
                      > > > > and I can see and select my focuser in the chooser when I run
                      >
                      > > MaxIm.
                      >
                      > > >
                      >
                      > > > > I have also been able to run the application in debug mode
                      and can
                      >
                      > > >
                      >
                      > > > > step through the code.
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > What I am having trouble with, and to be honest this is no
                      doubt
                      >
                      > > >
                      >
                      > > > > purely my lack of knowledge with vb.net, is how to set a
                      variable
                      >
                      > > >
                      >
                      > > > > such as MaxStep.
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > MaxStep is read only and according to the books the only way
                      to
                      >
                      > > set a
                      >
                      > > >
                      >
                      > > > > value for a read only property is to define it in the
                      constructor.
                      >
                      > > >
                      >
                      > > > > The constructor appears to be at the top of the program, and
                      >
                      > > implies
                      >
                      > > >
                      >
                      > > > > that my code should be in the following routine:
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > Public Sub New()
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > IFocuser.MaxStep = 1000 ' My code
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > ' TODO Implement your additional construction here
                      >
                      > > >
                      >
                      > > > > End Sub
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > Whatever I do, however, and I have tried many things, the
                      program
                      >
                      > > >
                      >
                      > > > > still gives an error saying that MaxStep is read only.
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > Can anyone shed some light on this matter to get me on the
                      right
                      >
                      > > >
                      >
                      > > > > track?
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > Regards
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > Peter
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > --- In ASCOM-Talk@yahoogroups.com, "Larry Weber" <larryweber@>
                      >
                      > > >
                      >
                      > > > > wrote:
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Markus,
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > I think Tim makes a good point.
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > One fun way to climb this learning curve is to take the VB
                      >
                      > > source
                      >
                      > > >
                      >
                      > > > > code for the Focuser Simulator and then run it in VB under
                      debug
                      >
                      > > >
                      >
                      > > > > mode. For starters, I would put a breakpoint at the
                      beginning of
                      >
                      > > >
                      >
                      > > > > each subroutine in the Focuser Class. Then get some program
                      that
                      >
                      > > can
                      >
                      > > >
                      >
                      > > > > control ASCOM focusers such as MaxIm DL or FocusMax, and
                      connect
                      >
                      > > one
                      >
                      > > >
                      >
                      > > > > of them to the Focuser Simulator. When you do this with the
                      >
                      > > Focuser
                      >
                      > > >
                      >
                      > > > > Simulator source code running under VB in debug mode, a
                      focuser
                      >
                      > > >
                      >
                      > > > > operation that is initiated in MaxIm or FocusMax will talk to
                      the
                      >
                      > > >
                      >
                      > > > > version of Focuser Simulator that you are running in debug
                      mode.
                      >
                      > > Any
                      >
                      > > >
                      >
                      > > > > command initiated by MaxIm or FocusMax will hit one of the
                      >
                      > > >
                      >
                      > > > > breakpoints you have set. You can step through the source
                      code,
                      >
                      > > >
                      >
                      > > > > examine the variables and see how it all works.
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Once you get through this exercise, you can make your own
                      >
                      > > version
                      >
                      > > >
                      >
                      > > > > of the Focuser Simulator and put in some of the code for your
                      >
                      > > >
                      >
                      > > > > focuser. Pick the Focuser class Move subroutine first and
                      put in
                      >
                      > > >
                      >
                      > > > > some code that will cause your focuser to move. Maxim has a
                      >
                      > > feature
                      >
                      > > >
                      >
                      > > > > for manually moving the focuser under Telescope Control on the
                      >
                      > > >
                      >
                      > > > > Focuser tab. Or you could click the Jog button in FocusMax
                      to do
                      >
                      > > >
                      >
                      > > > > manual control. Any way you do it, you will gain confidence
                      and
                      >
                      > > >
                      >
                      > > > > learn a lot just by seeing your focuser move under the
                      control of
                      >
                      > > >
                      >
                      > > > > either MaxIm or FocusMax.
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Larry
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > ----- Original Message -----
                      >
                      > > >
                      >
                      > > > > > From: Tim Long
                      >
                      > > >
                      >
                      > > > > > To: ASCOM-Talk@yahoogroups.com
                      >
                      > > >
                      >
                      > > > > > Sent: Sunday, March 02, 2008 2:44 PM
                      >
                      > > >
                      >
                      > > > > > Subject: RE: [ASCOM] Bit of help writing Focuser Driver
                      using
                      >
                      > > VB
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > I think you really need to read through the ASCOM focuser
                      >
                      > > >
                      >
                      > > > > standard and get an understanding of what all the properties
                      and
                      >
                      > > >
                      >
                      > > > > methods are supposed to do. You then have to add your own
                      code to
                      >
                      > > >
                      >
                      > > > > each property and method that is applicable to your device to
                      >
                      > > make it
                      >
                      > > >
                      >
                      > > > > perform as described in the standards document.
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > --Tim
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > From: ASCOM-Talk@yahoogroups.com [mailto:ASCOM-
                      >
                      > > >
                      >
                      > > > > Talk@yahoogroups.com] On Behalf Of billerwellm
                      >
                      > > >
                      >
                      > > > > > Sent: 02 March 2008 07:51
                      >
                      > > >
                      >
                      > > > > > To: ASCOM-Talk@yahoogroups.com
                      >
                      > > >
                      >
                      > > > > > Subject: [ASCOM] Bit of help writing Focuser Driver using
                      VB
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Hi,
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > It's my first time writing a driver and my VB experience
                      is
                      >
                      > > very
                      >
                      > > >
                      >
                      > > > > little. I have built a focuser using a servo motor and have it
                      >
                      > > >
                      >
                      > > > > controlled via a slide bar GUI using VB (not ASCOM compliant).
                      >
                      > > Please
                      >
                      > > >
                      >
                      > > > > see below:-
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Option Explicit
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Private Sub Form_Load()
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > 'These are key properties in controlling
                      >
                      > > >
                      >
                      > > > > > 'scrolling behavior
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > VScroll1.SmallChange = 1 'how much to change value on
                      arrow
                      >
                      > > click
                      >
                      > > >
                      >
                      > > > > > VScroll1.LargeChange = 15 'how much to change value on
                      scroll
                      >
                      > > >
                      >
                      > > > > > VScroll1.Min = 117 'minimum value (set to text box top)
                      >
                      > > >
                      >
                      > > > > > VScroll1.Max = 195 'maximum value (set to text box height
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > VScroll1.Value = 157 'set vscroll mid start point
                      >
                      > > >
                      >
                      > > > > > Text2(0).Text = VScroll1.Value
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > With MSComm1
                      >
                      > > >
                      >
                      > > > > > 'make sure the serial port is not open (by this
                      program)
                      >
                      > > >
                      >
                      > > > > > If .PortOpen Then .PortOpen = False
                      >
                      > > >
                      >
                      > > > > > 'set the active serial port
                      >
                      > > >
                      >
                      > > > > > .CommPort = 1
                      >
                      > > >
                      >
                      > > > > > 'set the badurate,parity,databits,stopbits for the
                      >
                      > > connection
                      >
                      > > >
                      >
                      > > > > > .Settings = "9600,N,8,1"
                      >
                      > > >
                      >
                      > > > > > 'set the DRT and RTS flags
                      >
                      > > >
                      >
                      > > > > > .DTREnable = True
                      >
                      > > >
                      >
                      > > > > > .RTSEnable = True
                      >
                      > > >
                      >
                      > > > > > 'enable the oncomm event for every reveived character
                      >
                      > > >
                      >
                      > > > > > .RThreshold = 1
                      >
                      > > >
                      >
                      > > > > > 'disable the oncomm event for send characters
                      >
                      > > >
                      >
                      > > > > > .SThreshold = 0
                      >
                      > > >
                      >
                      > > > > > 'open the serial port
                      >
                      > > >
                      >
                      > > > > > .PortOpen = True
                      >
                      > > >
                      >
                      > > > > > End With 'MSComm1
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > End Sub
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Private Sub VScroll1_Change()
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Text2(0).Text = VScroll1.Value ' provides reset slide bar
                      >
                      > > value
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > With MSComm1
                      >
                      > > >
                      >
                      > > > > > 'make sure the serial port is open
                      >
                      > > >
                      >
                      > > > > > If .PortOpen = False Then .PortOpen = True
                      >
                      > > >
                      >
                      > > > > > 'send the data (including a tailing carriage return as
                      >
                      > > often
                      >
                      > > >
                      >
                      > > > > needed)
                      >
                      > > >
                      >
                      > > > > > .Output = Chr$(1) ' Select which servo to drive
                      >
                      > > >
                      >
                      > > > > > .Output = Chr$(VScroll1.Value)
                      >
                      > > >
                      >
                      > > > > > End With 'MSComm1
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > VScroll1.Value = 157
                      >
                      > > >
                      >
                      > > > > > Text2(0).Text = VScroll1.Value ' provides reset slide
                      bar
                      >
                      > > value
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > End Sub
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Private Sub VScroll1_Scroll()
                      >
                      > > >
                      >
                      > > > > > Text2(0).Text = VScroll1.Value ' provides reset slide
                      bar
                      >
                      > > value
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > With MSComm1
                      >
                      > > >
                      >
                      > > > > > 'make sure the serial port is open
                      >
                      > > >
                      >
                      > > > > > If .PortOpen = False Then .PortOpen = True
                      >
                      > > >
                      >
                      > > > > > 'send the data (including a tailing carriage return as
                      >
                      > > often
                      >
                      > > >
                      >
                      > > > > needed)
                      >
                      > > >
                      >
                      > > > > > .Output = Chr$(1) ' Select which servo to drive
                      >
                      > > >
                      >
                      > > > > > .Output = Chr$(VScroll1.Value)
                      >
                      > > >
                      >
                      > > > > > End With 'MSComm1
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > End Sub
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Basically a couple of values are sent to the PIC using the
                      >
                      > > >
                      >
                      > > > > `MSComm1.Output' command to tell the servo what to do via a
                      com
                      >
                      > > port.
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > I have downloaded and set up the focuser template from
                      ASCOM
                      >
                      > > but
                      >
                      > > >
                      >
                      > > > > I have no idea what code to put in the TODO areas. Say in the
                      >
                      > > case of
                      >
                      > > >
                      >
                      > > > > the code below, am I right in assuming (please tell me if I'm
                      >
                      > > wrong)
                      >
                      > > >
                      >
                      > > > > I just put a set value in place of the TODO sentence relating
                      to
                      >
                      > > my
                      >
                      > > >
                      >
                      > > > > focuser for what ever controlling software is wanting to
                      speak to
                      >
                      > > the
                      >
                      > > >
                      >
                      > > > > focuser? If so what should the code defining that value look
                      like?
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Public ReadOnly Property MaxStep() As Integer
                      Implements
                      >
                      > > >
                      >
                      > > > > IFocuser.MaxStep
                      >
                      > > >
                      >
                      > > > > > ' TODO Replace this with your implementation
                      >
                      > > >
                      >
                      > > > > > Get
                      >
                      > > >
                      >
                      > > > > > Throw New PropertyNotImplementedException
                      >
                      > > ("MaxStep",
                      >
                      > > >
                      >
                      > > > > False)
                      >
                      > > >
                      >
                      > > > > > End Get
                      >
                      > > >
                      >
                      > > > > > End Property
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Same with the next bit of code. I assume (once again
                      please
                      >
                      > > tell
                      >
                      > > >
                      >
                      > > > > me if I'm wrong) this TODO requires me to use a values that it
                      >
                      > > sent
                      >
                      > > >
                      >
                      > > > > to my driver and move my focuser that amount. Is this where I
                      >
                      > > would
                      >
                      > > >
                      >
                      > > > > use the 'MSComm1.Output' command to send the value to the PIC.
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Public Sub Move(ByVal val As Integer) Implements
                      >
                      > > IFocuser.Move
                      >
                      > > >
                      >
                      > > > > > ' TODO Replace this with your implementation
                      >
                      > > >
                      >
                      > > > > > Throw New MethodNotImplementedException("Move")
                      >
                      > > >
                      >
                      > > > > > End Sub
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > The rest of the template is pretty much down the same
                      path.
                      >
                      > > So
                      >
                      > > >
                      >
                      > > > > if I get an understanding of these 2 I should hopefully be
                      able to
                      >
                      > > >
                      >
                      > > > > work out the rest. I have looked around for some completed
                      focuser
                      >
                      > > >
                      >
                      > > > > code using the ASCOM template without any luck. If anyone can
                      >
                      > > direct
                      >
                      > > >
                      >
                      > > > > me to some it would be much appreciated. Otherwise if someone
                      >
                      > > could
                      >
                      > > >
                      >
                      > > > > please show me an example of what I could put in the TODO
                      parts
                      >
                      > > that
                      >
                      > > >
                      >
                      > > > > would be great also.
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Thanks for taking to time to read my question.
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Cheers,
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > > > Markus
                      >
                      > > >
                      >
                      > > > > >
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > For more information see http://ASCOM-Standards.org/.
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > To unsubscribe from this group, send an email FROM THE
                      ACCOUNT YOU
                      >
                      > > > USED
                      >
                      > > >
                      >
                      > > > > TO SUBSCRIBE(!) to:
                      >
                      > > >
                      >
                      > > > > ASCOM-Talk-unsubscribe@yahoogroups.com
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > Yahoo! Groups Links
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > http://groups.yahoo.com/group/ASCOM-Talk/
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > Individual Email | Traditional
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > http://groups.yahoo.com/group/ASCOM-Talk/join
                      >
                      > > >
                      >
                      > > > > (Yahoo! ID required)
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > mailto:ASCOM-Talk-digest@yahoogroups.com
                      >
                      > > >
                      >
                      > > > > mailto:ASCOM-Talk-fullfeatured@yahoogroups.com
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > ASCOM-Talk-unsubscribe@yahoogroups.com
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > > > > http://docs.yahoo.com/info/terms/
                      >
                      > > >
                      >
                      > > > >
                      >
                      > > >
                      >
                      > >
                      >
                      > >
                      >
                      > >
                      >
                      > >
                      >
                      > > For more information see http://ASCOM-Standards.org/.
                      >
                      > >
                      >
                      > > To unsubscribe from this group, send an email FROM THE ACCOUNT YOU
                      > USED
                      >
                      > > TO SUBSCRIBE(!) to:
                      >
                      > > ASCOM-Talk-unsubscribe@yahoogroups.com
                      >
                      > >
                      >
                      > >
                      >
                      > > Yahoo! Groups Links
                      >
                      > >
                      >
                      > > http://groups.yahoo.com/group/ASCOM-Talk/
                      >
                      > >
                      >
                      > > Individual Email | Traditional
                      >
                      > >
                      >
                      > > http://groups.yahoo.com/group/ASCOM-Talk/join
                      >
                      > > (Yahoo! ID required)
                      >
                      > >
                      >
                      > > mailto:ASCOM-Talk-digest@yahoogroups.com
                      >
                      > > mailto:ASCOM-Talk-fullfeatured@yahoogroups.com
                      >
                      > >
                      >
                      > > ASCOM-Talk-unsubscribe@yahoogroups.com
                      >
                      > >
                      >
                      > > http://docs.yahoo.com/info/terms/
                      >
                      > >
                      >
                    • Tim Long
                      Peter, the questions you are asking are really general programming issues rather than anything to do with ASCOM. If you want to carry on this discussion with
                      Message 10 of 16 , Mar 8, 2008
                      • 0 Attachment

                        Peter, the questions you are asking are really general programming issues rather than anything to do with ASCOM. If you want to carry on this discussion with me off-list (Live Messenger Tim (at) tigranetworks.co.uk) then I am more than happy to do that, but perhaps this is a bit off-topic here. I will just answer this one last question here on the list, though.

                         

                        A property can be either set to a value or queried to get the current value back. The Set part sets the value and the Get part reads the value. No revelations there.

                         

                        Often, properties are used as a wrapper around some private piece of data. Most often (ignoring ASCOM for the moment) a property has a 'backing store' that stores its value. In VB it might like something like this:

                         

                        Public Class MyClass

                            Private privateData As Integer

                            Property MyProperty() As Integer

                                Get

                                    Return privateData

                                End Get

                                Set(ByVal value As Integer)

                                    privateData = value

                                End Set

                            End Property

                        End Class

                         

                        Now that is the simplest implementation of a property and probably doesn’t explain why you wouldn’t just make privateData public. You can actually implement any arbitrary code in the Get and Set accessors. In the case of an ASCOM focuser Link property, you may or may not set a backing store but you would probably have some code that configured your serial port device and made it go online or offline. A real-world example from one of my telescope drivers (again sorry for the syntax change to C#, but I’m sure you’ll get the idea). This is the Connected property, which is pretty much equivalent to the Focuser’s Link property.

                         

                                /// <summary>

                                /// Gets or sets the connection state. When setting the state, the serial port may be opened

                                /// or closed to match the requested state. Redundant operations (opening a port that is

                                /// already open) are allowed but ignored.

                                /// </summary>

                                public bool Connected

                                {

                                    get

                                    {

                                        bool IsConnected = awr.IsOnline;

                                        Diagnostics.TraceVerbose("Connected <- " + IsConnected.ToString());

                                        return IsConnected;

                                    }

                                    set

                                    {

                                        bool WasConnected = awr.IsOnline;

                                        Diagnostics.TraceInfo(String.Format("Connected {0} -> {1}", WasConnected, value));

                                        if (value)

                                        {

                                            awr.Open();

                                            // The open apparently succeeded but dont believe it until we get confirmation.

                                            if (!awr.IsOnline)

                                            {

                                                Diagnostics.TraceError("Serial port open failed - port reported offline");

                                                throw new ApplicationException("Failed to open serial port. Open apparently succeeded but then the port reported that is was offline.");

                                            }

                          //[...some code removed for clarity...]

                                            if (CanSetTracking && Properties.Settings.Default.ASCOMAutoTrackOnUnpark)

                                            {

                                                            Diagnostics.TraceInfo("Auto-enable tracking on connect");

                                                Tracking = true;

                                            }

                                                      Diagnostics.TraceInfo("===== Initialisation complete - Drive System is connected.");

                                        }

                                        else

                                        {

                                            awr.Close();

                                        }

                                    }

                                }

                         

                         

                         

                         

                        Best regards,

                        Microsoft Most Valuable ProfessionalTiger Relief.png

                        Tim Long

                        Owner & Technology Consultant

                        TiGra Networks

                        The Small Business IT Specialists

                        01443 208678 | www.tigranetworks.co.uk

                         

                         

                         

                         

                        > -----Original Message-----

                        > From: ASCOM-Talk@yahoogroups.com

                        [mailto:ASCOM-Talk@yahoogroups.com] On

                        > Behalf Of peterjchance

                        > Sent: 07 March 2008 08:57

                        > To: ASCOM-Talk@yahoogroups.com

                        > Subject: Re: [ASCOM] Bit of help

                        writing Focuser Driver using VB

                        >

                        > Hi Tim

                        >

                        > I think you believe I am further ahead that I

                        actually am..

                        >

                        > What I am doing at the moment is to make my own

                        version of a

                        > simulator so that I can get to grips with the

                        program. Once I have

                        > done that I will move on to the real thing.

                        >

                        > The question I asked, therefore, was how I should

                        connect to the

                        > simulator, not a real live focuser.

                        >

                        > I have now managed to connect but don't believe I

                        have done what is

                        > really required.

                        >

                        > What I have done is:

                        >

                        >     Public Sub New()

                        >         Link

                        = True

                        >     End Sub

                        >

                        > #Region "ASCOM Registration"

                        >

                        >

                        >     Public Property Link() As

                        Boolean Implements IFocuser.Link

                        >         Get

                        >             Return

                        True

                        >             'Throw

                        New PropertyNotImplementedException("Link", False)

                        >         End

                        Get

                        >         Set(ByVal

                        Value As Boolean)

                        >             'Throw

                        New PropertyNotImplementedException("Link", True)

                        >         End

                        Set

                        >     End Property

                        >

                        > This is the only way I could get it to link, but as

                        I said it's not

                        > right. I had to comment out all action in the Set to

                        get it to

                        > connect as I didn't know what to do there, and I

                        don't think it will

                        > dis-connect.

                        >

                        > If you could throw some light on what the Set part

                        of the routine is

                        > for it would be a great help.

                        >

                        > I will keep your last message for future use, as I

                        will have to

                        > tackle that problem later.

                        >

                        > Thanks for you help, it's much appreciated.

                        >

                        > Peter

                        >

                        > --- In ASCOM-Talk@yahoogroups.com, "Tim

                        Long" <Tim@...> wrote:

                        > >

                        > > To answer the second question first, set a

                        breakpoint on the Set

                        > part of

                        > > the property. Sometimes it can be tricky to

                        debug ASCOM drivers

                        > because

                        > > they are loaded into an external application.

                        The way to do that is

                        > to

                        > > start the application (POTH, perhaps) and then

                        in the Visual Studio

                        > > Debug menu, select Attach to Process... (carry

                        on my example, you

                        > would

                        > > then browse to POTH.exe and attach to it - then

                        when you hit

                        > Connect in

                        > > POTH, you should hit your breakpoint and be

                        able to single-step

                        > through

                        > > your code).

                        > >

                        > >

                        > >

                        > > Now for the first question. I'm afraid this

                        code segment may not

                        > make

                        > > much sense to you because it is in C# and not

                        VB. But this is how I

                        > set

                        > > up my serial port...

                        > >

                        > >

                        > >

                        > > using System.IO.Ports;

                        > >

                        > > //... lots of code deleted ...

                        > >

                        > >       

                        private SerialPort port = null;   // Deliberately

                        > uninitialised

                        > > until Open() called.

                        > >

                        > >       //... lots

                        of code deleted ...

                        > >

                        > >        

                        /// <summary>

                        > >

                        > >        

                        /// Go online or offline or query whether the serial port is

                        > > online.

                        > >

                        > >        

                        /// Transitioning from Offline to Online resets all

                        > > communications parameters.

                        > >

                        > >         ///

                        Going online when the port is already online is allowed

                        > but

                        > > ignored.

                        > >

                        > >        

                        /// Any exceptions that occur are considered fatal and will

                        > > propagate up to the ASCOM layer.

                        > >

                        > >        

                        /// </summary>

                        > >

                        > >        

                        public void Open()

                        > >

                        > >        

                        {

                        > >

                        > >            

                        Diagnostics.TraceInfo("Go Online requested");

                        > >

                        > >            

                        if (port != null)

                        > >

                        > >            

                        {

                        > >

                        > >                

                        Diagnostics.TraceError("Disposing old port

                        > instance.");

                        > >

                        > >                           

                        port.Dispose();

                        > >

                        > >            

                        }

                        > >

                        > >            

                        else

                        > >

                        > >            

                        {

                        > >

                        > >                

                        Diagnostics.TraceVerbose("Configuring serial I/O

                        > > parameters.");

                        > >

                        > >                

                        try

                        > >

                        > >                

                        {

                        > >

                        > >                            

                        port = new SerialPort();

                        > >

                        > >                           

                        //port.DataReceived += new

                        > >

                        SerialDataReceivedEventHandler(port_DataReceived);

                        > >

                        > >                           

                        port.ErrorReceived += new

                        > >

                        SerialErrorReceivedEventHandler(port_ErrorReceived);

                        > >

                        > >                    

                        // The serial parameters are all set in the

                        > > App.config file so they can be changed

                        in-the-field.

                        > >

                        > >                    

                        port.PortName =

                        > > Properties.Settings.Default.SerialPortName;

                        > >

                        > >                    

                        port.BaudRate =

                        > > Properties.Settings.Default.SerialSpeed;

                        > >

                        > >                    

                        port.DataBits =

                        > > Properties.Settings.Default.SerialDataBits;

                        > >

                        > >                    

                        port.DtrEnable =

                        > > Properties.Settings.Default.SerialDTREnable;

                        > >

                        > >                    

                        //port.Encoding = Encoding.ASCII;

                        > >

                        > >                                  

                        //port.Encoding = Encoding.UTF8;

                        > >

                        > >                                   

                        port.Encoding = Encoding.Default;

                        > >

                        > >                    

                        port.Handshake =

                        > > Properties.Settings.Default.SerialHandshake;

                        > >

                        > >                    

                        port.NewLine = Protocol.EndCmd;

                        > >

                        > >                    

                        port.Parity =

                        > > Properties.Settings.Default.SerialParity;

                        > >

                        > >                    

                        //port.ParityReplace =

                        > Protocol.Newline;  //TODO:

                        > > Investigate the effect of doing this!

                        > >

                        > >                    

                        port.PortName =

                        > > Properties.Settings.Default.SerialPortName;

                        > >

                        > >                    

                        port.ReadBufferSize =

                        > >

                        Properties.Settings.Default.SerialReadBufferSize;

                        > >

                        > >                    

                        port.ReadTimeout =

                        > > Properties.Settings.Default.SerialReadTimeoutMs;

                        > >

                        > >                    

                        port.ReceivedBytesThreshold =

                        > >

                        Properties.Settings.Default.SerialReceivedBytesThreshold;

                        > >

                        > >                    

                        port.RtsEnable =

                        > > Properties.Settings.Default.SerialRTSEnable;

                        > >

                        > >                    

                        port.StopBits =

                        > > Properties.Settings.Default.SerialStopBits;

                        > >

                        > >                    

                        port.WriteBufferSize =

                        > >

                        Properties.Settings.Default.SerialWriteBufferSize;

                        > >

                        > >                    

                        port.WriteTimeout =

                        > >

                        Properties.Settings.Default.SerialWriteTimeoutMs;

                        > >

                        > >                    

                        port.Open();

                        > >

                        > >                    

                        if (!port.IsOpen)

                        > >

                        > >                    

                        {

                        > >

                        > >                        

                        throw new ApplicationException("Serial port

                        > > Open() succeeded but then reported that it was

                        not open.");

                        > >

                        > >        

                                    }

                        > >

                        > >                                  

                        // Sometimes when the port

                        > connects

                        > > there is garbage in the input buffer.

                        > >

                        > >                                  

                        // We'll try to flush it out here.

                        > >

                        > >                                  

                        port.DiscardOutBuffer();

                        > >

                        > >                                  

                        port.ReadExisting();

                        > >

                        > >                                  

                        port.DiscardInBuffer();

                        > >

                        > >        //...

                        other initialization not relevant to this example.

                        > >

                        > >

                        > >

                        > > Note that I store all of my serial parameters

                        in the

                        > > Application.settings file, with default values

                        set there rather than

                        > > hard-wired into the code. In C# the values are

                        accessed through

                        > > Properties.Settings.xxx - I think in VB you

                        would use

                        > My.Settings.xxx

                        > >

                        > >

                        > >

                        > > --Tim

                        > >

                        > >

                        > >

                        > >

                        > >

                        > > > -----Original Message-----

                        > >

                        > > > From: ASCOM-Talk@yahoogroups.com

                        [mailto:ASCOM-

                        > Talk@yahoogroups.com]

                        > > On

                        > >

                        > > > Behalf Of peterjchance

                        > >

                        > > > Sent: 06 March 2008 10:24

                        > >

                        > > > To: ASCOM-Talk@yahoogroups.com

                        > >

                        > > > Subject: Re: [ASCOM] Bit of help writing

                        Focuser Driver using VB

                        > >

                        > > >

                        > >

                        > > > Thanks Tim, you are absolutely right of

                        course, and I can now set

                        > up

                        > >

                        > > > my parameters as required.

                        > >

                        > > >

                        > >

                        > > > Could I ask you for a little more help, in

                        that I can't get the

                        > >

                        > > > focuser to connect. I have tried a variety

                        of things without

                        > luck. If

                        > >

                        > > > I can get it to connect I think I will be

                        able (hopefully) to

                        > manage

                        > >

                        > > > it from there.

                        > >

                        > > >

                        > >

                        > > > If you are willing to help, what should

                        happen in the following

                        > >

                        > > > routine:

                        > >

                        > > >

                        > >

                        > > >     Public Property

                        Link() As Boolean Implements IFocuser.Link

                        > >

                        > > >         ' TODO Replace this with

                        your implementation

                        > >

                        > > >         Get

                        > >

                        > > >            

                        Throw New PropertyNotImplementedException("Link",

                        > False)

                        > >

                        > > >         End Get

                        > >

                        > > >         Set(ByVal Value As

                        Boolean)

                        > >

                        > > >            

                        Throw New PropertyNotImplementedException("Link",

                        > True)

                        > >

                        > > >         End Set

                        > >

                        > > >     End Property

                        > >

                        > > >

                        > >

                        > > > And how do I ensure that that the routine

                        is run when I click on

                        > >

                        > > > connect?

                        > >

                        > > >

                        > >

                        > > > Hope you can help.

                        > >

                        > > >

                        > >

                        > > > Regards

                        > >

                        > > >

                        > >

                        > > > Peter

                        > >

                        > > >

                        > >

                        > > >

                        > >

                        > > >

                        > >

                        > > > --- In ASCOM-Talk@yahoogroups.com,

                        "Tim Long" <Tim@> wrote:

                        > >

                        > > > >

                        > >

                        > > > > There isn't enough information to go

                        on from the snippet you

                        > >

                        > > > posted, but

                        > >

                        > > > > it looks like you're trying to write

                        to the interface, which

                        > cannot

                        > >

                        > > > work

                        > >

                        > > > > because interfaces are abstract

                        definitions with no executable

                        > code

                        > >

                        > > > in

                        > >

                        > > > > them. If you used the template

                        focuser project provided with

                        > >

                        > > > Platform 5,

                        > >

                        > > > > then you should have a bunch of

                        methods and properties within a

                        > >

                        > > > #region

                        > >

                        > > > > called "IFocuser members".

                        One of those properties is MaxStep,

                        > >

                        > > > defined

                        > >

                        > > > > as follows:

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >        Public ReadOnly Property

                        MaxStep() As Integer Implements

                        > >

                        > > > > IFocuser.MaxStep

                        > >

                        > > > >

                        > >

                        > > > >              

                        ' TODO Replace this with your implementation

                        > >

                        > > > >

                        > >

                        > > > >              

                        Get

                        > >

                        > > > >

                        > >

                        > > > >                      

                        Throw New

                        > >

                        > > > >

                        PropertyNotImplementedException("MaxStep", False)

                        > >

                        > > > >

                        > >

                        > > > >              

                        End Get

                        > >

                        > > > >

                        > >

                        > > > >        End Property

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > > You need to edit that code to simply

                        return your MaxStep value.

                        > So

                        > >

                        > > > if

                        > >

                        > > > > your MaxStep was 5000, you might do

                        something like:

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >        Public ReadOnly Property

                        MaxStep() As Integer Implements

                        > >

                        > > > > IFocuser.MaxStep

                        > >

                        > > > >

                        > >

                        > > > >              

                        ' TODO Replace this with your implementation

                        > >

                        > > > >

                        > >

                        > > > >              

                        Get

                        > >

                        > > > >

                        > >

                        > > > >                     

                        Return 5000

                        > >

                        > > > >

                        > >

                        > > > >              

                        End Get

                        > >

                        > > > >

                        > >

                        > > > >        End Property

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > > Best regards,

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > > Tim Long

                        <http://community.tigranetworks.co.uk/blogs/Tim_Long>

                        > >

                        > > > >

                        > >

                        > > > > Owner & Technology Consultant

                        > >

                        > > > >

                        > >

                        > > > > TiGra Networks

                        > >

                        > > > >

                        <http://community.tigranetworks.co.uk/blogs/TiGraNetworks/>

                        > >

                        > > > >

                        > >

                        > > > > The Small Business IT Specialists

                        > >

                        > > > >

                        > >

                        > > > > 01443 208678 |

                        www.tigranetworks.co.uk

                        > >

                        > > > <http://www.tigranetworks.co.uk>

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > >

                        > >

                        > > > > > -----Original Message-----

                        > >

                        > > > >

                        > >

                        > > > > > From: ASCOM-Talk@yahoogroups.com

                        [mailto:ASCOM-

                        > >

                        > > > Talk@yahoogroups.com]

                        > >

                        > > > > On

                        > >

                        > > > >

                        > >

                        > > > > > Behalf Of peterjchance

                        > >

                        > > > >

                        > >

                        > > > > > Sent: 05 March 2008 00:14

                        > >

                        > > > >

                        > >

                        > > > > > To: ASCOM-Talk@yahoogroups.com

                        > >


                        (Message over 64 KB, truncated)

                      Your message has been successfully submitted and would be delivered to recipients shortly.