Shop OBEX P1 Docs P2 Docs Learn Events
Mill OS modifications — Parallax Forums

Mill OS modifications

Mike GreenMike Green Posts: 23,101
edited 2006-10-16 22:16 in Propeller 1
Here is the changed Mill OS. I changed ReadByte and WriteByte to use the routines in OS_loader and modified changeXpos and changeYpos to keep the values in the high end of EEPROM memory in case you want to just load from RAM. I also added two calls to ReadLong in your start routine to read the values from the high end of EEPROM. Give this a try.
«1

Comments

  • NewzedNewzed Posts: 2,503
    edited 2006-09-26 15:11
    Mike, I loaded V1.20 into my Propeller board which has a pullup on SCL.· It would not save the posits when I rebooted.· Is this version only for the Demo board which has no SCL pullup?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-26 15:40
    Sid,
    I'll have to look again at the I2C code. It does check specifically for the boot EEPROM pins and assumes that there's no pullup on SCL. It should work whether there's a pullup or not (if you assume there's none, it should work if there is one). I'll let you know.
    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-09-26 23:01
    Mike, I don't have the vaguet idea of what I am doing, but I tried changing several things in V1.20, all to no avail.· Just ahead of where you wrote:

    · xpos := ReadLong($7FE8)
    · ypos := ReadLong($7FEC)

    I added a line:

    WriteLong($7FE8,50)

    When I booted up, the VGA said X = 0.· Does that tell you anything?

    Sid
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-26 23:08
    Doesn't help. Thanks for trying. I tested the EEPROM routines with the boot EEPROM (without a pullup on SCL) and on another EEPROM on pins 0/1 with a pullup and both appeared to work fine. Now they don't seem to work when there's a pullup on the boot SCL. The code takes a slightly different path when using pins 28/29 (to always drive SCL) and anything else (letting the pullup define HIGH) and I just have to go over that again. Now that I have a PropStick, I can test the "pullups on boot EEPROM" case.
  • NewzedNewzed Posts: 2,503
    edited 2006-09-26 23:16
    Mike, I have to make a board for a VGA Module - when I finish that, I'll bring the Demo board in here and see if V1.20 will work on it.

    Sid



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-09-27 12:54
    Mike, I decided to postpone the VGA Module boards, so I brought my Demo board in here this morning.· I was really anxious to see if V1.20 would work.· Changed the vga startgroup, loaded the program in EEPROM and it worked beautifully.· Then I loaded the program into RAM, changed the values of X and Y, rebooted and let the program in EEPROM come up, and the new posits were right there.· I then pushed the Reset button on the Demo board, and when the program came back up the posits were still there.

    So......this program will work ONLY if the is no pullup on SCL.· That is fine with me.· The only place I need to save the posits is when I running the mill - I don't need to save them when I am dry-running a new etch program in here.· My mill program is now as perfect as I could ask for.· V1.20 will now be the running version - I'll delete V1.10.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-27 14:50
    Congratulations Sid. Thanks for the information. That tells me what I have to look for. Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-09-28 18:41
    Mike, any progress on the SCL pullup-no pullup problem?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-28 19:06
    Sid,
    I've got a busy couple of days and will probably not get to it until Sunday evening. I'm working a couple of evenings (at my real job) and have all-day workshops through Sunday. Hopefully I'll have the whole day Monday to work on it too.
    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-10-02 19:02
    Mike, in the CON block of the mill program we have cycle = 600.· I have always assumed that this was in microseconds.· Is this correct?· We write:

    waitcnt(cycle + cnt)

    and I am trying to correlate it with the statement:

    waitcnt(clkfreq + cnt) where clkfreq = 80,000,000 which equals one second.

    It would appear that if 80,000,00 = 1 second then 600/80000000 would equal .0000075 = 7.5us.

    Can you straighten me out?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-02 19:40
    Right. The number in the WAITCNT is in clock ticks, so WAITCNT(600 + cnt) would wait 7.5us on a Propeller with an 80 MHz clock.

    If you want "cycle" to be in microseconds, you have to write WAITCNT(cycle * (clkfreq / 1_000_000) * cycle + cnt)". This will take the current clock frequency (stored at location zero in HUB RAM by the SPIN compiler or by a CLKSET call) and compute the number of clock ticks per microsecond, add it to "cycle", then add "cnt" and wait until then.

    If you noticed, I changed calls to PAUSE(x) to be WAITCNT(x*clkfreq/1000 + cnt) to give waits in units of one millisecond.

    If you're doing short waits, be careful of overflow on multiplication. 80000000 is roughly $05000000. If you multiply this by much more than 50, it will overflow.

    Post Edited (Mike Green) : 10/2/2006 7:46:07 PM GMT
  • NewzedNewzed Posts: 2,503
    edited 2006-10-02 19:54
    Thanks,· Mike.· I'm happy with the way things are written now.· I just wanted to make sure about the waitx and waity pauses.· I have been running the X axis at 40, which = 40 x 7.5us = 300us pause between pulses, and the Y axis at 120, which = 120 x 7.5 = 846us pause.· I reset the X to 30 and the Y to 90, which =··225us and ·775us respectively.· The mill is now etching about 4 inches per minute on both axes.· This is about a 33 percent increase in speed, which is great.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-10-02 23:35
    Mike, I'm having a bit of a problem.· When the Prop receives a certain byte from the Stamp I want it to display a DAT list.· I wrote:

    elseif byteval == "F"
    ··········· text.out(0)
    ··········· text.str(string("Received Command F ",13,13))
    ··········· text.str(word[noparse][[/noparse]@@reply1])
    ··········· waitcnt(clkfreq*2 + cnt)
    ··········· initialize·

    Here is the DAT list:

    reply1· WORD· "Communication with the Stamp is terminated",0

    Where did I go wrong?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-03 00:29
    You made the text.str statement too complicated. Try "text.str(@reply1)"

    The "@@" operator is used when you have a table of addresses which is not the case here.

    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-10-03 11:59
    Mike, I tried that and all I get is the first letter of the string.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-10-03 12:31
    Mike, I wrote:

    ····· z := 0
    ····· repeat z from 0 to 41
    ······· text.str(@reply1[noparse][[/noparse]z])
    ····· waitcnt(clkfreq*5 + cnt)

    and it displays the entire string.· Is there an expression I can substitute for "41" that defines the unknown length of a string?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-03 13:52
    I just noticed that you used WORD instead of BYTE when you defined the string.
    reply1 WORD "test",0
    
    


    compiles the same as
    reply1 BYTE "t",0,"e",0,"s",0,"t",0,0,0
    
    


    That's why you only got the first letter.

    Normally, you can use STRSIZE(@reply1) to get the length of a string.
  • NewzedNewzed Posts: 2,503
    edited 2006-10-03 14:09
    Got it, Mike - thanks.· Should have remembered that!

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-10-05 22:28
    Mike, I'm over my head again.

    I have the Prop and the 6-LED touch switch working well.· The way it is set up, only the Stamp can terminate communications.· I would like for the Prop to be able to do the same - some sort of command like a Trap in PBasic that Prop would read after every operation, and if I pressed say "Q", the Prop would terminate and re-initialize both Stamp and Prop.· The re-initialzation I think I can handle, but I don't know how to do the Trap equivalent.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-05 22:52
    The easiest way to do this is with the ABORT statement in SPIN. Any place you want to be able to detect a "quit", you put a test after each call to key.key or whatever you use. You then put an if statement that checks to see if a "Q" has been entered. If so, you do an "ABORT". In your main program start routine, when you call the next level, use a backslash. That will catch the ABORT (read the SPIN manual for details and examples). I use that in the OS's command interpreter to catch command format errors. This doesn't reinitialize anything, but it does take control back to a known place where you can reinitialize whatever you want and start over. Normally, when you return from a call, the default return value is zero (or false). If you use "ABORT TRUE", you'll get the TRUE value instead and can check for it.

    This won't do anything for the Stamp. You could have a reset command for the Stamp that you send (and interpret in your Stamp program) or you can bring the Stamp reset line to the Propeller and do a hardware reset using a Propeller pin.
  • NewzedNewzed Posts: 2,503
    edited 2006-10-06 16:01
    Mike, I read all about Abort and tried a couple of things, but I couldn't get it to do what I wanted.· So...........when in the communication mode, the Prop is always sitting at "recdata" waiting for a signal from the Stamp.· I went to recdata and wrote:

    PUB recData
    · if· key.getkey == false·······················
    ··· byteval := serialIn(1,stampBaud,sim#NInv,8)
    ··· startin····
    · else
    ··· initialize

    What I was trying to say was "If no key has been pressed, go ahead and receive data.· If a key has been pressed then initialize".· It doesn't work.· The Prop can not receive a signal from the Stamp, but if I press a key, the Prop initializes.· I think my "if key.getkey" statement is wrong.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-06 21:10
    Sid,
    You really have to read the description of the routine you're using. In the standard keyboard driver (including the one in the OS), key.getkey reads:
    '' Get next key (may wait for keypress)
    '' returns key
    
    


    If no key is available, the routine does hang waiting for one. You probably want to use "key.key" which returns a zero (false) if there's no key available and the actual key code if there is one.
  • NewzedNewzed Posts: 2,503
    edited 2006-10-06 22:27
    Mike, I wrote:

    PUB recData
    · if key.key
    ··· byteval := serialIn(1,stampBaud,sim#NInv,8)
    ··· text.out(13)
    ··· start3
    · else
    ···· text.str(string(13,"Propeller is terminating communications",13,13))
    ···· senddata("Q")
    ···· initialize

    As soon as I opened communication with the Stamp, the Propeller immediately terminated it.· Did I write it correctly?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-06 22:34
    Sid,
    I think you've got it backwards. The "if key.key" succeeds if a key has been pressed. The "else" succeeds if no key has been pressed. You could try changing the if statement to "if key.key == 0"
    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-10-07 12:42
    Mike, I have it working - sort of.

    I wrote:

    PUB recData
    · if key.key == 0
    ··· byteval := serialIn(1,stampBaud,sim#NInv,8)
    ··· startin····
    ··· text.out(13)
    · else
    ···· text.str(string(13,"Propeller is terminating communications",13,13))
    ···· senddata("Q")
    ···· start1

    What happens is that when I press a key to terminate, the Prop is already at the "byteval" instruction, so I must send one more command from the Stamp touch LED before Prop sees the key.key instruction, which it has stored.· This is not exactly what I wanted.· I don't think there is any really "clean" way to do what I want - I thought about making the key.key instruction a "repeat x" with a small delay, but if I made it long enough to give me time to press a key this would probably slow the program down to an unacceptable level.· I think I'll just go back to my original program and let the Stamp terminate communications.· Thanks for the help anyway - I've learned something new.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a TV Module?

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-10-13 14:30
    Mike, I need a bit of help again.

    I have an Inventroy program that works fine.· If I enter "2803" the screen returns:

    ULN2803· Qty 4
    Press any key to continue

    When the quantity of an item changes, I have to go into the DAT list and type in new figures.· I would like to be able to change the quantity of a part when I call it up.· I realize that I will have to rewrite the whole line - I can't just changed the quantity figure.· Here is the actual DAT entry:

    item2Desc· byte "ULN2803··· Qty 4",0··

    Can you tell me how to change it to:

    item2Desc· byte "ULN2803··· Qty 3",0

    on the fly, so to speak.

    Thanks

    Sid



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Don't have VGA?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-13 15:10
    Sid,
    The descriptor strings could be changed, but what happens when the quantity goes from 9 to 10? That requires two characters in the string instead of one. If you still have the original example I wrote for you, you may remember that I used a separate binary value for the quantity and displayed it with the ".dec()" method. That was intended for just this purpose since it's easy to change a binary quantity. One question for you is "where are you going to store the inventory numbers when the Propeller is turned off?" Do you have extra EEPROM attached or some other kind of persistent memory? If so, what about backup? You can afford to reenter the coordinates of the mill if you have to, but reentering inventory numbers is not an option, particularly if you haven't kept a copy somewhere of the latest ones.
    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-10-13 15:25
    Mike, I think you are telling me that I can not change a DAT entry on the fly unless I want to write it to EEPROM.· Right now the quantities are stored in the DAT list, which is reloaded every time I reboot.· Looks like I'll just have to go into the DAT lists and change the quantity, then SAVE the program.· Oh, well - I thought maybe there was an easier·way.· I'll just keep on doing what I'm doing now.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Don't have VGA?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-13 15:46
    Sid,
    You can change the DAT entry on the fly if you want to. You're just going to get burned the first time the power goes off and you lose the current inventory numbers.
    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-10-13 16:37
    OK - how do I change the DAT entry?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Don't have VGA?

    Newzed@aol.com
    ·
Sign In or Register to comment.