November 21, 2024, 09:59:41 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Error During Syntax check

Started by davisgraveyard, August 12, 2017, 12:14:18 PM

Previous topic - Next topic

davisgraveyard

It has been YEARS since I've programmed a Prop2.  I am trying to add some functionality into an old program.  I am getting a "Data occupies same location as program"  message when checking my syntax.  Does this mean my program is too big?


davisgraveyard

checked Parallax fourm and found that this is a too big issue.

So I've got it down to this set of IF's I am testing to see if previous variables have changes either less more more and then increase/decrease them as needed.



    DO WHILE (pos1 <> pos1_2 OR pos2_2 <> pos2 OR pos3_2 <> pos3)
      repeats = repeats_2
      IF (pos1 < pos1_2) THEN  pos1 = pos1 + 1
      IF (pos1 > pos1_2) THEN  pos1 = pos1 - 1
   '   IF (pos2 < pos2_2) THEN  pos2 = pos2 + 1
   '   IF (pos2 > pos2_2) THEN  pos2 = pos2 - 1
   '   IF (pos3 < pos3_2) THEN  pos3 = pos3 + 1
   '   IF (pos3 > pos3_2) THEN  pos3 = pos3 - 1
      GOSUB Run_Record
     LOOP


JonnyMac

Yes, your program has grown to the point where the code space is impinging on the data space; the Memory Map function allows you to see how the program is filling memory. I'm guessing that your program has some sort of data table -- can you make it a little smaller to provide more room for code?

FWIW, it's always very difficult to troubleshoot complex problems like these when only fragments are posted.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

yes the program has 400 lines of data in it and using he memory map there are only a few bites lefts for program space.

Sorry I didn't post the entire program.  I know better.     The code is 9 years old.  The data was originally created from puppeteering using a PropSX.  But the 3000 lines of movement data it created was too big for the Prop2.  So I wrote a compressing routine to get it down to 400 lines.  But the problem has always been that movement is jerky.   I opened this code back up originally to remove some PWM code that faded up LED eyes because now I am using LCD Eyes and just want to HIGH/LOW the 12v pin.  When I discovered I didn't have the most recent code that used the AP-16 and had to update the code I thought hey, maybe I could fix the jerky motion.  But allas I can't find the original 3000 lines of data and don't really want to recreate the PropX motions again.

So my thought was that I'd save the last set of servo values and then increment any changes in the new set by 1 at a time.  But the code barely fit before.  I didn't even have room to try this.  Based on your suggestion my other thought is to take a look at the data and see if I can figure out the movement pattern and save just the X,Y,Z values as start and stop and use code to fill in the transitions?





' =========================================================================
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ I/O Definitions ]-------------------------------------------------
Sio             PIN     14                      ' no ULN, SETUP = UP
eyes            PIN     0                       ' LED eyes
Servo1          PIN     8
Servo2          PIN     9
Servo3          PIN     10

' -----[ Constants ]-------------------------------------------------------
T2400           CON     396
T38K4           CON     6
T9600           CON     84
REC_LEN         CON     4
EOS             CON     $FFFF
SevenBit        CON     $2000
Inverted        CON     $4000
Open            CON     $8000
Baud            CON     Open + T38K4            ' baud jumper out
Addr            CON     %00                     ' both address jumpers out
YES             CON     1
NO              CON     0


' -----[ Variables ]-------------------------------------------------------

record          VAR     Word
pntr            VAR     Word
pos1            VAR     Word
pos2            VAR     Word
pos3            VAR     Word
repeats         VAR     Byte
pos1_2          VAR     Word
pos2_2          VAR     Word
pos3_2          VAR     Word
repeats_2       VAR     Byte
status          VAR     Byte
Playing         VAR     status.BIT7             ' 0 = idle, 1 = playing


' -----[ Initialization ]--------------------------------------------------

Reset:
  SEROUT Sio, Baud, ["!AP16", Addr, "X"]
  OUTH = %00000000
  DIRH = %10000111

  record = 0
  GOSUB Read_Record                             ' get starting positions

' -----[ Program Code ]----------------------------------------------------

Main:

  HIGH eyes
  PAUSE 10000

  GOSUB Refresh_Servos
  GOSUB Play_WAV                                ' play it

Play_Show:
  record = 1
  DO
    GOSUB Read_Record                             ' get new record

    IF (pos1 = EOS) THEN EXIT                    ' show done?

    DO WHILE (pos1 <> pos1_2 OR pos2_2 <> pos2 OR pos3_2 <> pos3)
      repeats = repeats_2
      IF (pos1 < pos1_2 AND pos1_2 <> 0) THEN  pos1 = pos1 + 1
      IF (pos1 > pos1_2 AND pos1_2 <> 0) THEN  pos1 = pos1 - 1
     ' IF (pos2 < pos2_2 AND pos2_2 <> 0) THEN  pos2 = pos2 + 1
     ' IF (pos2 > pos2_2 AND pos2_2 <> 0) THEN  pos2 = pos2 - 1
     ' IF (pos3 < pos3_2 AND pos3_2 <> 0) THEN  pos3 = pos3 + 1
     ' IF (pos3 > pos3_2 AND pos3_2 <> 0) THEN  pos3 = pos3 - 1
      GOSUB Run_Record
     LOOP

    GOSUB Run_Record
    record = record + 1

    GOSUB Get_Status
    IF Playing = NO THEN GOTO End_Show

  LOOP


End_Show:
  LOW eyes

  PAUSE 60000
  PAUSE 60000
  GOTO Reset

' -----[ Subroutines ]-----------------------------------------------------

Play_WAV:
  SEROUT Sio, Baud, ["!AP16", Addr, "PW", "SFX", CR, 1]
  RETURN

' -------------------------------------------------------------------------

Get_Status:
  SEROUT Sio, Baud, ["!AP16", Addr, "G"]        ' get status
  SERIN  Sio, Baud, [status]
  RETURN

' -------------------------------------------------------------------------

Read_Record:
  pos1_2 = pos1
  pos2_2 = pos2
  pos3_2 = pos3
  repeats_2 = repeats
  pntr = record * REC_LEN
  READ (Show + pntr), pos1, pos2, pos3, repeats
  RETURN

' -------------------------------------------------------------------------

Refresh_Servos:
  PULSOUT Servo1, pos1 * 5
  PULSOUT Servo2, pos2 * 5
  PULSOUT Servo3, pos3 * 5
  PAUSE 20
  RETURN

Run_Record:
   DO WHILE (repeats > 0)                      ' run the record
    GOSUB Refresh_Servos
    repeats = repeats - 1                      ' update record timer
   LOOP
   RETURN

' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------

'     pos1       pos2        pos3    tix

Show DATA 164,161,162,20
DATA 172,161,162,20
DATA 178,161,162,13
DATA 183,161,162,13
DATA 188,161,162,20
DATA 190,161,162,29
DATA 190,161,162,16
DATA 189,161,162,13
DATA 177,161,162,12
DATA 164,162,162,12
DATA 154,162,162,12
DATA 140,161,162,12
DATA 133,161,162,12
DATA 127,162,162,12
DATA 124,162,162,12
DATA 123,162,162,12
DATA 124,162,162,29
DATA 125,162,162,14
DATA 125,161,162,12
DATA 127,162,162,17
DATA 131,161,162,12
DATA 140,161,162,15
DATA 146,161,162,13
DATA 150,161,162,13
DATA 153,155,162,13
DATA 154,151,162,17
DATA 155,148,162,17
DATA 155,152,162,12
DATA 156,162,162,15
DATA 156,169,162,12
DATA 157,176,163,15
DATA 158,179,163,16
DATA 159,181,162,15
DATA 161,181,161,13
DATA 163,181,161,18
DATA 163,178,152,12
DATA 163,176,147,13
DATA 163,176,143,13
DATA 163,178,142,16
DATA 163,177,142,20
DATA 163,174,145,12
DATA 163,171,149,12
DATA 163,167,150,12
DATA 163,164,153,13
DATA 163,162,157,12
DATA 163,162,161,12
DATA 164,162,162,22
DATA 170,162,162,13
DATA 174,162,162,14
DATA 178,162,162,14
DATA 181,162,162,12
DATA 186,162,162,18
DATA 190,162,162,19
DATA 191,162,162,73
DATA 190,162,162,37
DATA 179,162,162,13
DATA 169,162,162,13
DATA 164,162,162,12
DATA 156,162,162,13
DATA 149,162,162,13
DATA 140,162,162,17
DATA 136,162,162,12
DATA 132,162,162,12
DATA 131,162,162,25
DATA 132,153,162,12
DATA 133,147,162,13
DATA 133,146,162,19
DATA 134,157,166,12
DATA 135,164,168,12
DATA 136,170,169,13
DATA 146,173,163,14
DATA 163,177,162,12
DATA 163,181,162,12
DATA 163,184,161,12
DATA 163,187,159,13
DATA 163,192,155,14
DATA 163,198,156,12
DATA 163,198,163,12
DATA 163,199,179,12
DATA 163,201,188,13
DATA 164,195,177,12
DATA 164,198,162,14
DATA 164,197,152,14
DATA 164,192,143,12
DATA 164,184,133,12
DATA 164,172,129,12
DATA 164,165,131,12
DATA 164,163,138,12
DATA 164,161,145,13
DATA 164,159,151,13
DATA 164,159,156,12
DATA 164,158,160,14
DATA 164,158,162,21
DATA 164,161,162,13
DATA 166,162,162,13
DATA 178,162,162,16
DATA 182,162,162,13
DATA 185,162,162,13
DATA 190,162,162,20
DATA 188,162,162,17
DATA 187,162,162,16
DATA 186,162,162,39
DATA 187,162,162,51
DATA 191,162,162,13
DATA 194,162,162,14
DATA 199,162,162,13
DATA 204,162,162,41
DATA 195,162,162,12
DATA 185,162,162,12
DATA 175,162,162,12
DATA 164,162,162,12
DATA 154,162,162,12
DATA 140,162,162,13
DATA 131,162,162,17
DATA 124,162,162,12
DATA 122,162,162,38
DATA 122,157,161,12
DATA 122,150,161,12
DATA 122,144,162,14
DATA 122,140,162,13
DATA 122,138,162,18
DATA 123,138,162,12
DATA 123,138,162,12
DATA 123,140,162,12
DATA 122,150,164,12
DATA 122,161,166,12
DATA 122,165,166,12
DATA 123,171,166,14
DATA 125,174,164,12
DATA 136,173,164,12
DATA 148,172,164,12
DATA 155,171,162,12
DATA 125,165,162,12
DATA 130,162,162,14
DATA 129,162,162,12
DATA 143,162,162,12
DATA 164,162,162,13
DATA 173,162,162,12
DATA 151,162,162,12
DATA 135,162,162,14
DATA 157,162,162,13
DATA 165,162,162,12
DATA 162,162,162,17
DATA 163,162,162,38
DATA 164,162,158,12
DATA 169,161,162,14
DATA 179,161,162,13
DATA 187,161,162,12
DATA 196,161,162,13
DATA 203,161,162,12
DATA 202,161,162,14
DATA 200,161,162,17
DATA 197,161,162,17
DATA 195,162,162,18
DATA 194,150,161,12
DATA 193,143,161,13
DATA 191,129,162,12
DATA 187,126,162,15
DATA 183,121,162,22
DATA 191,121,162,20
DATA 204,121,162,57
DATA 204,126,162,12
DATA 204,145,163,12
DATA 204,161,163,12
DATA 204,168,162,12
DATA 203,178,160,12
DATA 201,185,157,14
DATA 181,188,157,12
DATA 164,187,160,12
DATA 163,189,161,12
DATA 152,187,162,12
DATA 142,184,162,13
DATA 133,182,162,13
DATA 130,174,162,13
DATA 126,161,162,12
DATA 122,161,162,50
DATA 123,143,162,12
DATA 124,132,162,15
DATA 125,159,162,12
DATA 125,159,162,12
DATA 126,141,162,12
DATA 127,147,162,12
DATA 127,158,162,13
DATA 127,161,162,22
DATA 129,161,162,18
DATA 124,161,162,12
DATA 123,161,162,15
DATA 133,161,162,15
DATA 145,161,162,12
DATA 159,161,162,12
DATA 163,161,162,19
DATA 168,161,162,12
DATA 177,161,162,16
DATA 184,161,162,13
DATA 187,161,162,16
DATA 192,161,162,12
DATA 198,161,162,12
DATA 204,161,162,27
DATA 201,161,162,12
DATA 196,161,162,13
DATA 194,161,162,26
DATA 195,161,162,17
DATA 185,161,162,12
DATA 173,161,162,13
DATA 165,161,162,12
DATA 163,161,162,17
DATA 163,155,162,12
DATA 164,153,162,14
DATA 164,148,162,13
DATA 164,142,162,14
DATA 164,138,162,14
DATA 164,147,165,14
DATA 164,158,174,13
DATA 164,161,177,12
DATA 174,165,177,12
DATA 185,167,178,12
DATA 193,171,179,13
DATA 200,174,172,13
DATA 201,178,163,12
DATA 198,179,161,12
DATA 198,179,161,13
DATA 203,171,161,12
DATA 204,162,162,17
DATA 204,161,162,71
DATA 195,161,162,12
DATA 182,161,162,13
DATA 173,161,162,12
DATA 164,161,162,20
DATA 161,162,162,12
DATA 160,162,162,12
DATA 156,162,162,13
DATA 149,162,162,13
DATA 146,162,162,14
DATA 141,162,162,14
DATA 137,162,162,13
DATA 133,162,162,15
DATA 131,162,162,13
DATA 127,162,162,17
DATA 124,162,162,19
DATA 122,162,162,104
DATA 122,161,162,29
DATA 125,161,162,12
DATA 129,161,162,13
DATA 133,161,162,13
DATA 136,161,162,12
DATA 139,161,162,12
DATA 144,161,162,12
DATA 151,161,162,12
DATA 163,158,162,13
DATA 163,148,162,12
DATA 163,144,162,18
DATA 163,139,164,12
DATA 163,135,162,15
DATA 163,131,162,15
DATA 163,147,162,12
DATA 163,159,162,12
DATA 163,164,162,15
DATA 163,171,162,13
DATA 163,177,162,16
DATA 163,181,160,12
DATA 163,182,153,12
DATA 163,180,147,13
DATA 164,178,141,12
DATA 164,179,138,14
DATA 164,179,136,14
DATA 168,177,133,12
DATA 176,175,133,12
DATA 188,170,135,12
DATA 190,163,138,12
DATA 194,159,143,12
DATA 198,151,147,12
DATA 204,145,158,12
DATA 204,143,162,15
DATA 205,148,162,12
DATA 205,154,162,14
DATA 205,161,162,42
DATA 205,147,162,12
DATA 205,133,162,12
DATA 204,127,162,12
DATA 198,126,162,13
DATA 173,128,162,12
DATA 164,129,162,14
DATA 164,126,162,13
DATA 164,144,162,12
DATA 164,162,160,12
DATA 164,168,159,12
DATA 164,176,161,23
DATA 164,162,162,14
DATA 165,157,162,18
DATA 170,161,162,12
DATA 185,161,162,12
DATA 194,161,162,12
DATA 202,161,162,12
DATA 204,161,162,27
DATA 192,161,162,12
DATA 180,161,162,12
DATA 169,161,162,12
DATA 164,161,162,19
DATA 156,161,162,14
DATA 150,161,162,14
DATA 143,161,162,12
DATA 139,161,162,16
DATA 135,161,162,12
DATA 131,161,162,12
DATA 127,161,162,16
DATA 123,161,162,15
DATA 122,161,162,32
DATA 130,161,162,12
DATA 136,161,162,15
DATA 142,161,162,12
DATA 149,161,162,14
DATA 154,147,161,13
DATA 155,140,161,12
DATA 154,152,163,14
DATA 154,162,163,14
DATA 154,166,162,12
DATA 154,176,162,14
DATA 156,182,158,12
DATA 160,183,148,12
DATA 163,181,148,12
DATA 169,174,154,12
DATA 180,171,161,12
DATA 184,173,164,12
DATA 194,177,166,12
DATA 203,175,162,13
DATA 204,168,156,12
DATA 204,158,151,12
DATA 204,153,162,12
DATA 197,151,169,12
DATA 197,140,158,12
DATA 195,143,152,12
DATA 164,149,164,12
DATA 139,152,165,12
DATA 128,155,164,12
DATA 129,158,162,12
DATA 129,160,159,13
DATA 128,161,160,13
DATA 130,161,154,12
DATA 136,156,151,13
DATA 137,146,152,12
DATA 138,142,155,12
DATA 138,138,155,13
DATA 139,133,155,13
DATA 139,133,161,13
DATA 139,139,165,12
DATA 139,147,176,12
DATA 140,158,178,12
DATA 147,161,174,12
DATA 162,163,172,12
DATA 165,163,169,12
DATA 174,164,166,12
DATA 180,165,162,12
DATA 181,167,158,12
DATA 185,167,154,12
DATA 198,164,162,15
DATA 204,163,169,12
DATA 204,158,175,12
DATA 204,148,176,12
DATA 204,140,177,12
DATA 204,133,175,12
DATA 195,124,167,12
DATA 182,121,166,12
DATA 168,121,166,13
DATA 164,121,165,13
DATA 155,125,162,12
DATA 144,132,162,12
DATA 141,141,162,12
DATA 148,148,162,12
DATA 156,154,162,12
DATA 161,156,162,13
DATA 157,147,165,12
DATA 163,148,164,12
DATA 164,158,162,13
DATA 164,161,162,15
DATA 163,147,162,12
DATA 163,125,162,12
DATA 163,121,162,13
DATA 167,121,162,13
DATA 179,122,162,12
DATA 192,124,162,12
DATA 177,126,162,12
DATA 162,126,162,12
DATA 139,128,162,12
DATA 131,132,163,13
DATA 138,141,164,12
DATA 159,155,164,12
DATA 163,161,163,12
DATA 163,161,162,20
DATA 142,161,162,12
DATA 131,161,162,24
DATA 127,161,162,13
DATA 122,161,162,28
DATA 124,161,162,15
DATA 126,161,162,12
DATA 130,161,162,12
DATA 137,161,162,12
DATA 144,161,162,13
DATA 162,161,162,12
DATA 163,162,162,14
DATA 163,168,162,12
DATA 163,174,162,12
DATA 163,178,162,12
DATA 163,183,162,15
DATA 163,188,162,13
DATA 163,191,162,13
DATA 163,192,161,15
DATA 163,153,166,12
DATA 163,125,187,12
DATA 163,121,174,12
DATA 176,121,163,12
DATA 202,127,161,12
DATA 163,130,163,12
DATA 126,132,174,12
DATA 122,135,173,14
DATA 124,135,168,14
DATA 130,135,161,13
DATA 130,149,135,12
DATA 133,152,138,14
DATA 138,150,147,12
DATA 153,146,159,12
DATA 156,146,161,12
DATA 164,149,162,12
DATA 163,154,162,12
DATA 163,161,162,20
DATA EOS,EOS,EOS,0

JonnyMac

Have you considered upgrading this to an HC-8+? That would get you 32K of combined RAM and -- more importantly -- you could run servos without worrying about manual updates because that is handled by a background process. With code space and a PWM driver, you could go back to fading eyes, too. The Serial port on the HC-8+ can be used to control the AP-16+ (that's what we did for Legoland). To top it off, you can create shows with Vixen, pop them onto a microSD card, and play them from the HC-8+

I know this is not the answer you're hoping for, but the BS2 is 20 years old and limited to what it can do vis-a-vis real-time servo control. You have several very long PAUSE statements in the program. During these PAUSE periods, the servos are not being updated as they should.

I did a basic code clean-up to recover some space, but there's just not enough room to transition from one place to the next. To do that, you'd have to calculate the delta between each of the moves divided by the time spent between each move, and then add that. You'd also have to test that you don't have any over- or under-shoot of positions (my Propeller servo driver does this when you apply speed ramping).

You'll have to reduce the move tables further to make room for ramping between records.

Sorry to be the bearer of bad news....

Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

I really wasn't trying to do much more with this Prop-2 program.  The only reason I even went to edit it was that I created some OLCD eyes than run off a Tiny Arduino and it just needs power to start up.  So I wanted to remove my PWM of the LED eyes I had and just have a HIGH/LOW on off of the eyes.  They blink open when powered on.   That's when I discovered I didn't have the recent AP-16 changes I made to the program.   So while I was updating the program I thought I'd see if making the movements would be a simple addition.  As you pointed out.  Not really.

https://learn.adafruit.com/animated-electronic-eyes-using-teensy-3-1/overview


My long term plan with the project is to convert to the Tiny Aurdino and run the 4 servos and play an audio file out an mp3 shield that also moves the jaw. 

https://www.adafruit.com/product/2756

https://www.adafruit.com/product/1788

But before I look at getting all the libraries I'll need and putting it all together I am writing a 3 axis skull animation simulator with a 3D model of a skull with moving jaw.  I am going to use it like a music maker.  Move the turn just the way I want and set it to repeat.  then add in some tilt and then nod with random pauses.  To create a movement loop that seems very natural.  Then write an realistic jaw movement routine based on audio FFT.   Once I have a natural random head movement and jaw movement routines I'll code up the arduino to do the work.

I'll probably just shelve the Prop-2 program movement improvements.  This year I added the OLCD eyes and a Monster Guts 3-axis rig to improve its movement reliability. 

http://www.monsterguts.com/store/product.php?productid=17782&cat=272&page=1

davisgraveyard

Did you say you made some improvements to the code?   I didn't see an attachment?  Or did you mean that after improvements you still couldn't get it to work any better so you didn't attach the changes?


davisgraveyard

August 13, 2017, 08:26:37 PM #7 Last Edit: August 13, 2017, 08:32:37 PM by davisgraveyard
So....what would the HC-8+ code look like?

I have 3 servos on P8,9,10  (Nod, Tilt,Turn)
LCD Eye power on OUT 0
LED spotlight power OUT 1 PWM
Serial IO on P14 to a AP-16+
the red and white wires are active on the pins.  The black wire is wired to external power  and everything to GND.

1. PWM the LED spotlight
2. Power on the LCD eyes
3. Start playing SFX.WAV
4. Read data and position servos Nod,Tilt,Turn X times 20ms (add smoothing code)
5.  Loop through all data checking if audio stops.  Start data over if audio still playing
6.  Power off LCD eyes
7.  PWM LED spotlight to off
8.  Wait 2 minutes
9.  Loop back to top

I have a HC-8+ labeled Rev C 2011 with a MicroSD board (c) 2012 on it






JonnyMac

Move your question to the HC-8+ forum and we'll take it up there. The great news is that you everything can be in your show data: servo positions, LED fading, even basic on-and-off.
Jon McPhalen
EFX-TEK Hollywood Office