Shop Learn
SPI SOLVED - Page 7 — Parallax Forums

SPI SOLVED

15791011

Comments

  • of course.
  • Ok then, I just calibrated the PWM for correct duty-cycle at 20kHz and tested it. I wondered why the manual says 96% rather than 100% for top speed but that seems to be because of the 50Hz (20ms) scan time and I guess in the original they may have bit-bashed the PWM, just like I'm doing now for this simple first test. I have also added a timeout on the controller if the handbox is not responding. Both units print diagnostic messages over the USB serial port and the handbox will flash the speed led to indicate communications is working.

    I will post the binary very shortly and let's see how it works.
  • Peter,
    The 96% was my idea. The manual did not map speed multiples to PWM.
    The Hand Box speed button options are 2x, 4x, 8x, 32x and 96% max PWM seemed like an easy multiple i.e. 96 = 32 x 3.
    The PWM mapping will have to be user calibrated.
    Maybe the user will prefer 32x speed= 80% PWM or something like that.
  • What's wrong with 100% and then 50% 25% 12.5% ? Why would you limit the maximum speed of the motor for the top setting. Doesn't matter for the moment anyway, just got to try it I guess. I'm just wrangling the hex dump back into a binary but for some reason the Prop loader doesn't like the checksum at address 5, so I'm just tracking down this little bug in my EEPROM hex dump routine.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-08-16 07:48
    Well I've been wondering why the loader didn't like the binary checksum but it turns out it had to do with the hex2bin converter utility and the wrong padding!^%&!

    Here is a binary that should run and also tell you want it going on when you are monitoring the USB port on either.
    btw, to monitor the USB ports set your terminal to 115200 baud. This is the console baud rate and has nothing to do with the Prop to Prop comms.
  • How do I adapt the Dual_motor_ez_MOD For use with the UDN2993 which only a enable for pwm and a phase for direction(0, 1)
  • ChrisGaddChrisGadd Posts: 280
    edited 2020-08-16 23:58
    The RA_SPEED pin and DEC_SPEED pin go to the UDN2993 enable pins, RA_DIR pin and DEC_DIR pin go to the UDN2993 phase pins, as indicated by the comments. But you shouldn't be adapting the Dual_motor_ez_MOD object at all, any changes to the pin assignments are in the Telescope_mount object.
    RA_SPEED  = 16                ' RA motor enable                                                               
      RA_DIR    = 17                ' RA motor phase                                                                
      DEC_SPEED = 18                ' Dec motor enable                                                              
      DEC_DIR   = 19                ' Dec motor phase                                                               
    
    bbrien wrote: »
    What I need to know is how do I add the files to my .library
    You just drop the files into the library folder, but why are you trying to add them to the library? When the Propeller tool compiles, it searches through the editor tabs, the working directory, and finally the library directory. You could extract the zip file to a folder that you create on the desktop (or where ever is easiest for you to locate), open the top file (check the _readme _.txt if unsure), and load it into EEPROM from there. No other action is necessary.


  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-08-17 02:59
    bbrien wrote: »
    of course.

    I mean, try it since it is a simple thing on your part to just load it onto both, and let me know since it is a simple thing on your part to do as well.

    btw, I know for some reason you are using a Flip just for the handbox, but if you really wanted to keep it simple and still on 4 wires you could have just used a 16-pin PCF8574 or similar to handle the LEDs and switches over a 2-wire I2C bus. So much simpler and no software needed for the handbox.
  • Chris I tried out the hand box program and it worked pretty good. Serial works when I trigger some pins. Some of your other post on various project also worked very good.
  • Peter; I looked at it and how do i load it . Most of the characters are not on my keyboard.
  • I tried copying the file to the prop tool library but it doesn't show up in the library or in demos.
  • Peter tell me more about this idea.I like a I2C to one cog . How do I set 5 Switches and 4 LEDs without any software. PLEASE enlighten me.
  • Chris Gadd Take a look at my C file for hand controller and help me set up in your spin.Other than that your program is ok.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-08-18 00:46
    You don't edit a binary, it is used to directly program the prop chip. When you compile, it generates a binary that is saved on you computer and then used to send program the Prop chip. You can then use this same binary again and again, especially if you making a bunch of Prop boards or you want to share something on the forum that anybody can try without having to know how to compile it.

    I don't know which tool you are using but just use Prop tool to load and program the binary if you are not sure since Prop tool will automatically come up with the program dialog.

    I2C I/O is super simple and while there is software on the controller end to talk to I2C, you only need the dumb chip on the handbox end. In Tachyon I simply say "$40 IO@" and it will read the 8 lines of the I2C chip at device address %0100000x. When I want to set just one led situated on the upper 4-bits of this port I could say "$EF $40 IO!" and then bit 4 of the port will be driven low, so the LEDs would be wired from +3.3V (active low) while the switches would be wired to ground (active low). This chip has pull-ups internally and can only drive the output low or read the pin.

    Note: When I say "say...." I'm talking about when Tachyon is loaded you can code this way or even talk to Tachyon via the serial terminal and just try it out interactively.
  • Jakacki's binary file is pretty easy to load. Just open the spin tool, click the post binary file and there it is, either load the ram or eeprom, it looks like it's a pretty good size. I haven't tested it but I'm pretty sure it will work. Or if I just click the binary post, and it will open the spin tool automaticlly.
  • DigitalBob wrote: »
    Jakacki's binary file is pretty easy to load. Just open the spin tool, click the post binary file and there it is, either load the ram or eeprom, it looks like it's a pretty good size. I haven't tested it but I'm pretty sure it will work. Or if I just click the binary post, and it will open the spin tool automaticlly.

    The binary is actually the whole Tachyon OS and only a couple of hundred bytes for the actual controller and handbox software and I always make it a 32k binary even though there is plenty of memory available, but code is down one end and dictionary and buffers up the other. So the complete dev/compiling/debugging environment is still there on the chip if you happen to want it, such as testing out I2C for instance.

    btw, we certainly have taken on a difficult task for something so very simple :smile:

  • Need instructions to copy from prop library into propeller tool IDE library.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-08-18 02:39
    bbrien wrote: »
    Need instructions to copy from prop library into propeller tool IDE library.

    I'm guessing you are asking someone else this question?

    Anyway, did you take the few seconds that it takes to load the binary and check it out? Then let me know?
    You know we are taking a bit of time here trying to help and we understand that you may be having difficulties but it is a basic courtesy to respond and acknowledge.
  • Without detailed instructions I cannot load the binary.I spent several hours trying to load into the ide. i have it in the propeller library library but only spin files can be loaded by me.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-08-18 06:30
    Please please show me what you have on your screen. Do a "printscreen" and post that.
    Loading a binary is the simplest way to load the Prop. Did you use the Spin tool (or Prop tool)?
    A binary is not the same as a library and I'm sure I didn't say anything about putting it there.
    Anyway, you shouldn't be spending several hours trying, you should work out what needs to be done, which you've already been told but you are making assumptions and changing what are very simple instructions.

    I don't know what you are using or what you are trying to do with it (hence the screenshots). If I lived across the road I could come over and see straight away what you were doing wrong, but I'm across an ocean, so you have to spell it out and describe it to me and if necessary take photos and screenshots etc. Then from across the ocean I will be able to see what you are doing wrong.
  • Changed source files in lower left corner to binary and retrieved the binary files and I see xinfreq = 10,000,000Hz. I only have 5MHz crystal.
  • I don't understand why you keep trying to fix something that has been supplied that works, especially when you have such limited knowledge in this field. This binary takes care of 5MHz or 10MHz crystals and sets the pll accordingly. Please just simply load it and try it.
  • I found a unused bar at the lower left corner called source files.spin and a drop down arrow,which I clicked on and found "binary files which I clicked on and found LX50 binary files and I noticed the xinfreq =10,000,000 Hz and my flips only have 5MHz crystals.
  • I loaded the binary files into the mount flip and turned on the serial monitor and nothing on the screen. Will have to check outputs for a signal since I have no idea of whats what.
  • Is there any means to convert a C program into the spin counterpart.
  • bbrien, I hesitate to respond to your posts, but your question about converting C to Spin caught my interest. I wrote a C-to-Spin converter a few years ago called cspin. I could try it on your C code if you want. Post your files, and I'll take a look at them.
  • bbrien wrote: »
    Chris Gadd Take a look at my C file for hand controller and help me set up in your spin.Other than that your program is ok.
    Before I do that, I have some questions:
    First - are the pin definitions in that C file accurate? If so, then those are the pin names that Mr. Jakacki asked for at the top of page 6. Would have been nice to know for the binary.
    Second - are you certain that the pin definitions in the C file are accurate? If so, then the handbox schematic is inaccurate with serial rx and tx being on pins 0 and 1. This would certainly explain the difficulty that DigitalBob had with trying to communicate with pins 20 and 21.
    Third - to clarify what you want, are you asking for my help in copying the pin definitions from the C file into the Spin file?
    Telescope1 master.c
    #define westPin          3
    #define northPin         4
    #define eastPin          5
    #define southPin         6
    #define modePin          7
    #define lowLedPin        24
    #define med1LedPin       25
    #define med2LedPin       26
    #define highLedPin       27
    
    #define rx 0
    #define tx 1
    
    Telescope handbox.Spin
    CON  ' Modify as needed
    'PIN ASSIGNMENTS
      NORTH  = 17     
      SOUTH  = 14     
      EAST   = 16     
      WEST   = 18     
      RATE   = 15     
    
      LED_1  = 10     ' Lit when the slowest speed is selected
      LED_2  = 11
      LED_3  = 12
      LED_4  = 13     ' Lit when the fastest speed is selected
    
      RX     = 21
      TX     = 20
    
    If that's what you're asking for, I'll get you started. NORTH = 4.
  • bbrien wrote: »
    I loaded the binary files into the mount flip and turned on the serial monitor and nothing on the screen. Will have to check outputs for a signal since I have no idea of whats what.

    I too hesitate to respond but as I have said, you have to load the exact same binary both to the controller and to the handbox for it to work obviously. If you want to monitor anything on either Flip's USB serial port you have to set the terminal to 115200 baud.
  • Guy's I've tested your work and I don't have any problems, everything looks good. The OP needs some training on the basics, and maybe Windows 101. Is what it is.
  • D,Hein; please refer to my post middle of this page"2020-08-17@11:44 to Chriss Gadd.

    ChrissGadd;The pin numbers change from time to time according to other peoples inputs.
    That was done a long time ago when I tried to do it in C. Always had trouble with serial and wanted to use I2C at first but found out Propeller couldn't slave.
Sign In or Register to comment.