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

Mill OS modifications

2»

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-13 17:54
    The DAT entry is just a string of characters. Assuming the unit count is the last thing in the string, you need to find the address of the last character (digitAdr) in the string given the address of the beginning of the string (stringAdr). This would be: "digitAdr := stringAdr + strsize(stringAdr) - 1". A simple routine to increment a digit string would be:
    carry := 1
    repeat until byte[noparse][[/noparse]digitAdr] < "0" or byte[noparse][[/noparse]digitAdr] > "9" or carry == 0
      if byte[noparse][[/noparse]digitAdr] == "9"   ' if already at "9", wraparound to "0" and leave carry as 1
        byte[noparse][[/noparse]digitAdr--] := "0"
      else
        byte[noparse][[/noparse]digitAdr--] += carry~  ' if not at "9", increment digit and change carry to 0
    
    


    If carry is still 1 at the end of the loop, an overflow has occurred.
  • NewzedNewzed Posts: 2,503
    edited 2006-10-13 21:21
    Mike, I studied your post and determined that the code you posted would increment inventory.· I would there fore need one method to increment, another to decrement.

    So I started off with:

    PUB invincr(nameaddr)········· 'increments inventiry by 1
    ·· digitAdr := nameaddr + strsize(nameaddr) - 1
    ·· carry := 1
    ·· repeat until byte[noparse][[/noparse]digitAdr] < "0" or byte[noparse][[/noparse]digitAdr] > "9" or carry == 0
    ··· if byte[noparse][[/noparse]digitAdr] == "9"·· ' if already at "9", wraparound to "0" and leave carry as 1
    ····· byte[noparse][[/noparse]digitAdr] := "0"
    ··· else
    ····· byte[noparse][[/noparse]digitAdr] += carry~· ' if not at "9", increment digit and change carry to 0
    ·· text.out(13)
    ·· text.out(13)
    ·· text.out(13)
    ·· text.str(nameaddr)
    ·· text.out(13)
    ·· text.str(string("Inventory incremented",13,13))
    ·· text.str(string("Press any key to continue"))
    ·· key.getkey
    ·· start2

    As you can see, I had to change several of the expressions to agree with my program.· The first time I ran it, it changed "ULN2803" to "ULN3803".· That made sense because the 2 in 2803 was the first number it ran into.· So I changed my DAT list to read "Qty··· 4" and ran it again.· It displayed "Qty··· 5", so the code works.

    I changed the "+=" in "byte[noparse][[/noparse]digitAdr] += carry~·" to "-=", reloaded ·and it displayed
    Qty = 3.· However,·as you pointed out, the whole exercise was almost pointless.· When I rebooted everything went back to what the DAT list said, but it has added a bit to my programming knowledge.· Maybe I'll start a new program and see if I can store inventory in EEPROM.· The program uses about 3800 longs so I should be able to get it in EEPROM (8000 longs) with no trouble.

    Sid

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

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-13 21:28
    Sid,
    For decrement, you have to change the carry to a borrow, not just change the += to a -=. In particular, change the "9" in the IF to a "0" and the following assignment from a "0" to a "9" (works just like you do it by hand).
    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-10-13 21:42
    Understood, Mike.

    Now back to an old problem.· I can not write to EEPROM with the Prop board I have in here because it has a pullup on SCL - remember?· Did you ever have time to solve that?· I suppose I could remove it and make it like the Demo board but I really hate to do that.

    Sid

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

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-13 21:52
    Sid,
    The current version of the EEPROM routines that I have seem to be able to read and write to EEPROM regardless of whether there is an SCL pullup or not. I can't test exactly your situation because, with the Demo Board, you can't really access the boot EEPROM pins, but I set up an EEPROM on pins 0/1 without an SCL pullup and fooled the routines into thinking that this was the boot EEPROM pins and it did work. I do need to package up these routines with the rest of the OS which has had some changes to ease compatibility among the 3 text display drivers. Anyway, it'll be a few days.
    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-10-13 22:00
    OK, Mike.· I can wait.· In the mean time, I think I will remove the pullup on SCL and ·install a couple of female headers in the holes.· That way I will have a choice as to whether there is a pullup or not.

    Sid

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

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-10-13 22:34
    Mike, in my mill program I have these two lines to recal xpos and ypos on reboot:

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

    Will I need similar entries in my Inventory program.· $7FE8 = 32744.· I have about 75 entries in the inventory DAT list.· If I allow 25 bytes for each entry and start at 32744 this would take me to 34619 = $873B.· OK?

    Sid

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

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-10-13 23:27
    Mike, I have separate methods for changex and changey in my mill program.· Will I need a separate method for each part I have in inventory?· Is there a limit to how many methods I can write?

    Sid

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

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-10-14 13:49
    Mike, I removed the pullup on SCL and loaded the mill program.· It would not save xpos and ypos like the Demo board does.· As far as I can tell, removing the pullup makes it just like the Demo board.· Can you think of any reason the Demo saves but my board does not?

    Sid

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

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-14 14:13
    There must be something about the wiring of SCL (and maybe SDA) on your board that's different. The I2C signalling scheme is supposed to be pretty robust over distances on the order of a foot or two, but it does require certain minimum (generous) rise and fall times to the pulses. What EEPROM part are you using? (and who's the manufacturer?)
  • NewzedNewzed Posts: 2,503
    edited 2006-10-14 14:29
    Mike, I'm using the 24LC256 made by Microchip.· The one on the Demo board is an SSOP.· The one on my board is an 8-pin DIP plugged into an 8-pin DIP.· Could that make a difference?

    Sid

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

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-10-14 15:24
    Mike, I changed:

    PRI WriteByte(location,contents)
    · ldr.writeEEPROM(ldr#i2cBootSCL << 18 + location, @contents, 1)
    · waitcnt(clkfreq / 50 + cnt)·

    to ' / 25 ' but that didn't help.

    Sid

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

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-14 15:37
    Sid,
    The Microchip part should work and it shouldn't make any difference what kind of package. The wait in the WAITCNT is very conservative. Anything over 5ms should be more than adequate (clkfreq / 200).
  • NewzedNewzed Posts: 2,503
    edited 2006-10-14 16:51
    Mike, I have tried everything I can think of, and I can not make the EEPROM work.· I read the address where the data is supposed to go - $7FE8 - and the screen returned a blank.· I would hate to have to buy another Demo board just to have EEPROM capability here in the office.

    Sid

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

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-14 17:38
    Sid,
    Take your board and trace out the connections for the EEPROM and everything that's connected to it and the Propeller's pins 28/29. Make a diagram and post it.
    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-10-14 17:52
    Here you are, Mike.

    Sid

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

    Newzed@aol.com
  • NewzedNewzed Posts: 2,503
    edited 2006-10-14 17:53
    Oops - pins on SCL and SDA are reversed.

    Sid

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

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-14 18:25
    Please include voltages and resistances
  • NewzedNewzed Posts: 2,503
    edited 2006-10-14 18:34
    Here again you are.

    Sid

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

    Newzed@aol.com
  • NewzedNewzed Posts: 2,503
    edited 2006-10-14 20:03
    Mike, I brought my Demo board in from the shop and loaded the inventory program.· It still doesn't work.· If I enable line 80, I get a blank screen when I key in "2803".

    I have attached the program - maybe you can spot what is wrong.· The 2803 is the only item I'm working with.

    Sid

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

    Newzed@aol.com
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-14 20:28
    Sid,
    I'll have a look at your program this evening. On your EEPROM, have you tried tying the 10K pullup to +3.3V instead of RESn? I don't know what else you have tied to that RESn line, but it might load it down enough to affect the use of the EEPROM. For booting, Chip probably drives the SDA line as well as the SCL line rather than counting on a passive pullup, but my routines count on that SDA pullup working properly.
    Mike
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-14 21:03
    Sid,
    Your program has lots of infinite recursion going on. Your "start2" routine calls other routines that call routines that end up calling "start2" again. Every time one of these "start2" calls occurs, more stuff gets pushed onto the stack and never gets popped off. Eventually, your program pushes stuff right on top of the display buffer and other important data. You're going to have to go through the program and rewrite these sections so they don't use routine calls like they were jumps.
    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-10-14 21:04
    Mike, on my board it also goes to the Rst pin on the Com2Prop loader; however, I disconnect the Com2Prop after the program is loaded, whch doesn't help.· Right now, I'm still playing with the Demo board but can't get anything to work right.

    Sid

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

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-10-16 12:04
    Mike, I think we can forget about the EEPROM-based inventory program.· First, if I ever had to make a change to the program, all the data in EEPROM would have to be reloaded.· Second, even if I had a perfect program, I would have to dedicate a Propeller to the inventory program.· So....I'll just stick to my DAT list approach.

    Thanks, anyway.

    Sid

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

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-10-16 22:16
    Mike, I thought I would see if I could store the inventory data in the slave Stamp.· It's working out pretty well.· I had to assign an item number to each part and I use the "gettravel" method from my mill program to enter the item numbers.· I'll have to make sure the Stamp program is perfect before I start loading everything into it - if I change the program I lose all the data.· I would like to be able to enter the actual part number,
    i.e., LM340, but I couldn't figure out a way to enter an alphanumeric word and give it a name i could use, hence the item number.· Besides, I think I would have to use a serstring on the Stamp to receive alphanumerics.· The Stamp is already dedicated so that is no problem.

    Sid

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

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