Shop OBEX P1 Docs P2 Docs Learn Events
SPI SOLVED - Page 6 — Parallax Forums

SPI SOLVED

13468911

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-08-13 05:45
    Great! Do you have names for the switches and leds? This information will be used in the software so that everything matches up, rather than pin numbers.
    Do you have a preference for Rxd and Txd labels on the serial comms? Assuming that pin 2 on the hand unit will be wired to pin 2 on the main unit etc.

    Same again for the motor drive although it's easy enough to change.
    Are there labels for the two 8-pin connectors and their pins and what are they used for?
  • Great! Do you have names for the switches and leds? This information will be used in the software so that everything matches up, rather than pin numbers.
    Do you have a preference for Rxd and Txd labels on the serial comms? Assuming that pin 2 on the hand unit will be wired to pin 2 on the main unit etc.

    Same again for the motor drive although it's easy enough to change.
    Are there labels for the two 8-pin connectors and their pins and what are they used for?

    Peter, I spent some time trying to establish the user requirements for the telescope control.
    I attach some documents which partially answer your questions.
    The Handbox buttons need to labelled on the schematics.
  • Peter, here is the Handbox User Requirement Iss 2 as reviewed by bbrien
  • No I dont at this time . I planned to do that when I do The Kicad drawings after I have a working system. Right now Every thing is on a large breadboard.
  • Have you tried out the master and slave programs just to test out your serial communication. They work with no problems as a serial test.
  • If you can't get a simple program to work, a more complex one isn't going to work either.
  • Sorry, I've been a bit busy and also for the next few hours but I should be able to give you a binary that you can load onto both Flips and if your schematic is correct then the software will start up in hand controller or main unit mode automatically. One of the things it will also do is blink the leds to confirm communications so even if your serial terminal is not correctly configured that will tell you that the software and internal serial comms are working.
  • Haven't had time to do the last one yet . Wife wont let me work on it .
  • Marco, the 2b-8 master and slave programs are the latest. The master looks good just a working version of the OP's original, The slave works good too but it's only for testing the serial connection to show how it reads the little endian bytes. I posted pictures of both the master and slave terminals. I benched tested it first to make sure it works. This is not how I would have done this project, I don't have a telescope and I'm not selling these as an upgrade so I can't devote much time re-inventing the wheel , I just tried to tweek whats was there. I hope Mr. Jakacki is busy building some of those P2 boards for production.
  • I just tried the latest tweeks and still nothing on the slaves monitor Just the blue buttons or lights for rx,tx,dsr and cts . Send me a picture of the display.
  • Look back on pages 2 and 3 of this thread.
  • picture is what I get on the Master terminal.
  • I already corrected these for you. I'm spinning my wheels here. I'm out
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-08-14 05:17
    Just got back in so I will check out my code and send you a binary soon that you can load directly into both. The flashing lights will tell you if it is working or not and from there we can check out the rest of the system.

    @DigitalBob - I'm busy designing boards, but I'm waiting to finish all of them and send them out so that I get paneled sets back in one hit, and then assembled one or two for initial testing. When it all checks out I will then assemble the rest.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-08-14 07:17
    Crosschecking all your signals and what they actually go to based on the circuit in the LX-50 provided, I see that you have +5V from a tiny TO92 liner regulator powering the L2993 and the motors. This seems wrong but that is what the LX-50 seems to do, so I guess they must be really low current motors. The Flip module may draw much more current than the PIC chip in the LX-50 though. edit: now I see the +12V going to the chip.

    Also you have +5V connected directly to the LED on the 5-pin motor connector without any series resistor, so this is probably dead now. Same with P15 connected directly to the other LED on that connector. However it looks like you have your pin number reversed anyway as 1&2 are the motor pins on the LX-50 but you are using 4&5. You may have to check all this and then make sure the LEDs are ok too.

    So I think I have it all correct now, I will go and check the code and at the very least once you have loaded it, then the handbox leds will provide feedback information and blink if it is communicating while the buttons will drive the motors etc.


  • i wrote this code a while earlier but I am going to connect up some P1 boards I have and test it out. The code is very simple and is exactly the same for both P1s and it does a test for a pulldown on P2 at startup to determine which section to execute.

    The handbox flashes all its leds 4 times at reset and does nothing more than repeatedly wait for a character from the master which specifies the speed LEDs to light up and then in response sends back the button character NSEWx or a null.

    The drive unit sends out the current speed LED character to the handbox and waits for a button code. The button code performs a 20 ms NSEWx action or waits 20ms so that the update cycle is 50Hz. The NSEW action will generate the correct PWM for 1/50s on that motor and if the button is still pressed it will continue this next cycle and so on.

    This is really only a quick test but should work and will provide serial activity information on the leds as well as diagnostic messages on the programming coms ports. If it functions correctly then the PWM method and coms timeouts would be cleaned up and other special modes integrated. The main thing first is to check that it functions. Being Tachyon you can also test out and exercise the hardware directly as well for further debugging.



    Here is the tentative source which could be pasted serially into an existing V5.7 Tachyon system but once I check out this code I will post the one binary that can be loaded directly onto both Flips.
    TACHYON 
    
    module LX50     PRINT" LX-50 TELESCOPE DRIVE & HANDBOX 200814.0000 " ;
    
    {
    
    LX50 DRIVE & HANDBOX test software
    This is a fairly simple test for bbrien's LX50 unit
    
    DRIVE
    The speed led status is transmitted serially to the handbox.
    The handbox sends back its switch status in response and is actioned.
    The PWM is a timed 1/50 pulse of bit-bashed PWM for one motor.
    It will continue to drive the motor while the button is pressed.
    Status messages are printed over the main comms ports.
    
    HANDBOX
    A simple loop will wait for a character from the drive unit to set the speed LEDS and
    then respond with a button code or a null.
    The Handbox'S active speed LED will blink to indicate serial activity.
    
    }
    
    --- DRIVE UNIT ---
    
    2   := J4.6   --- pulldowns
    3   := J4.5
    4   := J4.4
    5   := J4.3
    
    8   := J5.6
    9   := J5.5
    12  := J5.4
    13  := J5.3
    
    
    --- LX50 DRIVE UNIT ---
    
    --- RA EW MOTOR ---
    15  := LEDW   --- active high
    17  := ENA    --- PWM
    18  := PHA    --- DIR   --- W = CCW
    
    --- DEC NS MOTOR ---
    19  := ENB    --- PWM
    20  := PHB    --- DIR   --- N = CCW
    
    --- SERIAL COMMS TO HANDBOX ---
    11  := MTXD   --- J2.2
    10  := MRXD   --- J2.3
    
    byte _speed
    byte _new
    
    pri NEW?  _new C@ DUP IF _new C~ THEN ;
    
    
    pri SPEED
      NEW? IF _speed C++ CR PRINT" Speed is now " _speed C@ 3 * "  2x 8x16x32x" + 3 CTYPE THEN
      ;
    
    --- rough PWM    12%      24%       48%       96%
    TABLE speeds    6 | 42 | 12 | 36 | 24 | 24 | 48 | 0 | 
    
    pri PWMB 
      _speed C@ 3 AND 2* speeds + C@++ C@ ( off on )
      400 FOR ENB HIGH OVER us   ENB LOW DUP us   NEXT
      ;
    pri PWMA
      _speed C@ 3 AND 2* speeds + C@++ C@ ( off on )
      400 FOR ENA HIGH OVER us   ENA LOW DUP us   NEXT
      ;
    
    byte dots
    --- print a message on a new action or emit a dot for every continuing action
    pri MESSAGE
      NEW? IF CR PRINT$ ELSE dots C@ 7 AND 0= IF '.' EMIT THEN dots C++ THEN
      ;
    
    --- Move the motor at the set speed for 1/50 of a second and print a message .....
    pub NORTH   PHB HIGH PWMB  " North" MESSAGE ;
    pub SOUTH   PHB LOW PWMB   " South" MESSAGE ;
    pub EAST    PHA HIGH PWMA  " East" MESSAGE ;
    pub WEST    PHA LOW PWMA   " West" MESSAGE ;
    --- stop the motor (just in case) and reset new message flag
    pub STOP    _new C~~ ENB LOW ENA LOW ;
    
    
    pri ACTION
        SWITCH
        'N' CASE NORTH BREAK
        'S' CASE SOUTH BREAK
        'E' CASE EAST BREAK
        'W' CASE WEST BREAK
    --- not moving the motor so slow down the scan time to around 50Hz
        20 ms 
        'x' CASE SPEED BREAK 
        STOP SPINNER
      ;
    
    pub DRIVE
        CR PRINT" LX-50 DRIVE UNIT "
        STOP
    --- diagnostic flash
        4 FOR LEDW HIGH 100 ms LEDW LOW 100 ms NEXT
    --- x32 speed
        3 _speed C!
      BEGIN
    --- update 1of4 handbox leds based upon speed 0..3
        _speed C@ 3 AND MASK $30 + MTXD SEROUT
    --- then read response from handbox and execute
        MRXD SERIN ACTION
      AGAIN
      ;
    
    --- --- --- --- --- --- --- --- --- --- --- --- 
    
    --- HANDBOX ---
    
    3   := *SW1   --- active high pulldowns
    4   := *SW2
    5   := *SW3
    6   := *SW4
    7   := *SW5
    
    20  := HRXD   --- J2.2
    21  := HTXD
    
    {
    indicate speed
    }
    24  := LED1   --- active high
    25  := LED2
    26  := LED3
    27  := LED4
    
    pub GETSW ( -- code )
        *SW1 PIN@ IF 'N' BREAK
        *SW2 PIN@ IF 'S' BREAK
        *SW3 PIN@ IF 'E' BREAK
        *SW4 PIN@ IF 'W' BREAK
        *SW5 PIN@ IF 'x' BREAK
        0
        ;
    
    byte _blink
    
    pub LEDS ( mask -- )
    --- turn off all the LEDs   
        LED1 LOW LED2 LOW LED3 LOW LED4 LOW
    --- simple blink of LEDS (if there is communications)
        _blink C++ _blink C@ 4 AND IF DROP EXIT THEN 
    --- now turn them on according to the mask
        $0F AND LED1 << OUTSET
        ;
     
    
    pub HANDBOX 
        CR PRINT" LX-50 HANDBOX "
    --- diagnostic flash
       4 FOR $0F LEDS 100 ms 0 LEDS 100 ms NEXT
        BEGIN
    ---   wait for a character from the master & update the LEDs
          HRXD SERIN LEDS
    ---   response with the button code and send to the drive unit
          GETSW DUP HTXD SEROUT
    ---   and if a button is pressed then display it serially or spin |/-\
          ?DUP IF EMIT SPACE ELSE SPINNER THEN
        AGAIN
        ;
    
    
    { MAIN STARTUP
      Check if this is the drive unit or the handbox 
      If P2 is floating then this is the handbox
    }
    pub MAIN
        100 ms
        CR LX50
        9600 SERBAUD
    --- P2 pulsed high, wait, read high still is handbox
        2 HIGH 2 FLOAT 10 us 2 PIN@ IF HANDBOX ELSE DRIVE THEN
        ;
    
    ' MAIN +INIT 
    END
    
    


  • Peter,
    On behalf of the forum, thanks for stepping up and completely coding the Handbox Prop1 and the Control Prop1 for bbriens's telescope.
    I really hope this will help bbrien move forward.
    I was going to write conventional code for him and test it in a parlallel rig, but I do not have the time and resources right now (thanks to the virus).
    Based on previous problems you will have to guide bbrien painstakingly and at great detail through the workflow to get it working.
    I can see you are very busy with your cutting edge P2 work, so thanks in advance!
  • @macrobeak - I think he is genuine and has other difficulties but really wants to get this running. While I could code it in Spin, I find that a binary is a binary but with Tachyon there I can direct him to get into the guts of it easily to find out why it might not be working with tiny cut&paste one-liners.

    I am working on my pcbs right at the moment but when I feel I need a break from that for a while, I will setup my Props and check it out.

  • I seem to have a problem with the "project board as when I installed the master program into the proj. board the monitor displays Gibberish but when I use the Flip board everything works fine. Must order new boards.
  • bbrienbbrien Posts: 561
    edited 2020-08-14 17:55
    That's a UDN2993, Handles up to 400ma per channel. Actually its only 9v in my design, motors use 6-9v and are geared clock motors. Other devises on motors areoptical encoders which are not being used. No encoders used on Declination drive.
  • Here're a couple more programs you can try for the mount and the handbox. They test good on my Props; had two of 'em communicating with each other, 5 buttons and 4 leds on the handbox, autoguider inputs and motor controller outputs on the mount, looks good on my logic analyzer. You'll have to set the pin assignments as I couldn't glean them from your schematic and they seem to change throughout your posts.

    Also I cleaned up your schematic.
  • Chris,
    I repeat the thanks for you that I gave earlier to Peter;
    macrobeak wrote: »
    On behalf of the forum, thanks for stepping up and completely coding the Handbox Prop1 and the Control Prop1 for bbriens's telescope.
    I really hope this will help bbrien move forward.
    bbrien is lucky having you two alpha-coders to help him.
    I had a look through your code and the input and output seems to meet the requirements which have been articulated up to now.
    It is really tight code, easy to follow and well documented, so let us all hope it can be implemented and get this telescope up and gazing!


  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-08-15 15:52
    I wanted to double check the lx50 controller+handbox software that I wrote as a starter for bbrien and so I started to make up this lx50 circuit on a plug-in breadboard I happen to have lurking in the shadows. Now I remember why I dislike this plug-in stuff, all those wires looping around and having to work with this silly layout and components that don't sit quite right. Tomorrow I will start again on a couple of matrix boards, the ones with plated through holes and uncommitted pads. That way everything will go in properly and where it needs to be. (I'm doing this inbetween all my other stuff, when I need a small break)

    Here's a photo of that plug-in stuff I started. I decided to use a couple of my P8 modules that were designed for the IoT stuff I did years ago.
    1688 x 1356 - 154K
    1665 x 3648 - 455K
  • bbrienbbrien Posts: 561
    edited 2020-08-15 20:42
    Mines bigger and uglier, two motors and two banks of switches and lots of leds . next question the Obj Dual_motor_ex_MOD , is that in the ide library or do I write it in the program.
    2560 x 1920 - 986K
    2560 x 1920 - 1M
  • Instead of the flip, a prop project board may be a better way to go once ready to make permanent. Plenty of room for the hardware.

    @"Peter Jakacki" , I've used these breadboards for decades, but with solid wire cut to length from a spool or from the occasional kits.
  • bbrien wrote: »
    next question the Obj Dual_motor_ex_MOD , is that in the ide library or do I write it in the program.
    That is JonnyMac's dual-motor driver with one small edit, just use all the files in the zip, you don't need to write anything, it's all in the zip file.

    With the driver as originally written, setting the motor speed to 10_0 created a pulse that was high for 10% of the period with the direction output low, which is fine, while setting it to -10_0 created a pulse high for 90% of the period and high direction output. I've never used a h-bridge before, but from looking at the UDN2993 datasheet it seems that would run the motor at high speed in reverse.
  • bbrien wrote: »
    Mines bigger and uglier, two motors and two banks of switches and lots of leds . next question the Obj Dual_motor_ex_MOD , is that in the ide library or do I write it in the program.

    Wow! that's what we wanted to see from the beginning, warts and all, it doesn't matter. But I will hook-up something today if I can and test out my software and maybe even add those extra functions that are in the lx-50 manual. btw, even though I have an rx and a tx for the comms from the handbox, it really only needs a single rxtx line since the handbox only transmits after it receives a character, just like a ping-pong ball.
  • What I need to know is how do I add the files to my .library
  • If I give you a binary that you can load onto both units, will you try it? It should work even though I haven't tested it but either way it should flash some leds to show that it is going through the motions and communicating etc.
Sign In or Register to comment.