November 21, 2024, 11:24:38 PM

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.


Code not working

Started by davisgraveyard, October 16, 2023, 11:50:00 AM

Previous topic - Next topic

davisgraveyard

October 16, 2023, 11:50:00 AM Last Edit: October 16, 2023, 12:12:25 PM by davisgraveyard
I have a Prop1 running a program that is easily 10+yrs old.  I needed to make a change to the timing of one step when I replaced a relay switched jigsaw with a small 12v actuator that needed to run a bit longer.  So I dusted off my prop1 USB adapter and dug up what I think is the latest version of the .bs1 code (I'm surprised I had a copy) Made the change uploaded it to the Prop1 and now the code doesn't work.  It uses a sound triggered relay to activate but it is now not working.  I recall in the foggy cobweb filled part of my memory that I had issues with this and made some changes to make it more reliable but I think that version of the code is long gone.  I've tried the code on another prop1 with the same results.  Nothing else has changed.  It was working just before I made the code change.


SYMBOL Trigger          = PIN6              'Trigger pin
SYMBOL Sio              = 7                'serial I/O
SYMBOL IsOn            = 1
SYMBOL IsOff            = 0
SYMBOL i                = B0

' reset the devices
SEROUT Sio, OT2400, ("!!!!!AP8",%11,"X","!DC16",%11,"X")

'Wait for a trigger
Main:
DIRS = %10111111

IF Trigger = IsOff THEN Main

Force_Release:
IF Trigger = IsOn THEN Force_Release

it never gets to this point....

You cannot see attachments on this board.

You cannot see attachments on this board.

Jeff Haas

Hi, good to see you again!  I can see one thing you should change...this part loops on itself if the Trigger is on:

Force_Release:
IF Trigger = IsOn THEN Force_Release

This basically says, "if the trigger is pressed then go back to Force_Release" - when I think you want to go down to the rest of the code.

I know what it's like in the run-up to Halloween, so I took a crack at merging your code into JonnyMac's template for the BS1.  This adds the section for checking the trigger.  I don't have an AP-8 or DC-16, but I reviewed the docs and this looks pretty close.  Please give this a try and see how it goes.  I think the main logic that makes the sounds and the footsteps looks OK, but I don't know about the Power_Up and Reset sections at the top.

Otherwise this will loop in the Check_Trigger section until the relay is on, and then it will go down the rest of the code.

' =========================================================================
'
'   File...... DavisGraveyard Footsteps
'   Purpose...
'   Author.... DavisGraveyard, updated by Jeff Haas
'   E-mail....
'   Started...
'   Updated... 10/17/2023
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0

SYMBOL  TrOn            = 1                     ' active-high trigger
SYMBOL  TrOff           = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  i               = B0
SYMBOL  timer           = B2                    ' for debounce loop


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

Power_Up:
  SEROUT Sio, OT2400, ("!!!!!AP8",%11,"X","!DC16",%11,"X")

Reset:
  PINS = %00000000                              ' all off
  DIRS = %10111111                              ' Set up outputs


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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  PAUSE 5                                       ' scan delay
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 100 THEN Check_Trigger             ' check timer

  'make some step sounds first
  FOR i = 1 TO 7
    SEROUT Sio, OT2400, ("!AP8",%11,"P",0)
    PAUSE 1000
  NEXT

'light up the last 7 steps
  FOR i = 0 TO 6
    SEROUT Sio, OT2400, ("!AP8",%11,"P",0)
    SEROUT Sio, OT2400, ("!DC16",%11,"P",i,1)
    PAUSE 1000
    SEROUT Sio, OT2400, ("!DC16",%11,"P",i,0)
  NEXT

  PAUSE 1000
'rattle the solenoid
  HIGH 1
  PAUSE 7000
  LOW 1
  PAUSE 100

  GOTO main




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


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


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


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


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

davisgraveyard

I've tried this code version.  Still does not drop down into the rest of the code.  I have this connected to an audio relay trigger board.  But even if I just short the WR pins on Pin6  It doesn't trigger.  I have tried the code on 2 Prop1 boards.   

I can't figure out what is going on?

Jeff Haas

Do you have a Prop-1 Trainer board?  Try one of the demos for that and see if you can press the button and get the lights to blink.

Make sure the jumper for Pin 6 is on DN.

I also remembered something from the Prop-1 docs...look at your Prop-1 and check what the version is.  On the lower-right corner under the big chip is the version number.  There's this note at the bottom of the Prop-1 docs:

QuoteErrata
Rev B. boards have the P6 and P7 configuration jumpers reversed – the SETUP pins marked P6 are actually
connected to P7 and vice-versa. This error was corrected on boards marked "Rev C" and higher.

This means that if you have a Rev. B board, put the jumper for pin 6 on the config pins for pin 7, and vice versa.

davisgraveyard

October 26, 2023, 04:11:22 PM #4 Last Edit: October 26, 2023, 04:13:34 PM by davisgraveyard
the board I was using was a Rev C the ULN chip is only 8 pins instead of 9 so it is socketed starting at pin down from the notch.  This Board has been working for years.  In fact it was working this month.  Up until I loaded a newer version of the program to change the timing of the solenoid rattle. Now it isn't working at all.  I assumed it was my old version of the code I uploaded that had a flaw in the trigger logic.  The board itself has some corrosion on some of the board.  I have 3 Rev D Prop-1's in better shape with a ULN chip with 9 pins that fill the socket and have tested the code with them too and still don't get any response?   I have tried the Trainer with the test program and it works.  Odd thing is the Debug terminal doesn't seem to be working for any of these boards either?  I am using the BS1 Serial adaptor and the USB to 232 adaptor together with a USB cable to my PC's 2.0 USB port.


Jeff Haas

OK, I just took a closer look at the picture above...that's not an AP-8, that's an AP-16.  I have one of those, it takes SD cards for the sounds, it has two big amps on it for the speakers, and a relay to trigger a prop.

Do you have a version of the code for the AP-16?  If not I can spend a bit of time later and adapt yours.

davisgraveyard

Here is a photo of the entire prop

The concept here is that the Prop-1  is connected to the AP-16 and DC-16.  The AP-16 is used to play a 1sec audio footstep sound and the DC-16 is used to turn on a LED footstep.  Using the Prop-1 to send the serial commands in a pair the sound and lighted foot appear to be in sync.  There is a audio relay trigger board that takes a sound and turns on a relay that acts as the trigger.  We play a looping video and there is a loud sound that plays at the beginning of the video that triggers this effect.  The small solenoid relay board reverses polarity of the solenoid with 1 second timer so that when you apply the 12v power to it it will rattle the solenoid as long as the power is applied.

The entire setup has worked for MANY years and was working fine when we set this up the beginning of the month.  I then added the solenoid relay and solenoid and had to reprogram the prop1 to increase the delay for the solenoid rattle from 1 second to 7 seconds.  the old solution used a 15v DC jigsaw from Harbor Freight which was too violent but worked for years.  This new solenoid is more of a slow subtle gate rattle instead.  I don't think this is a hardware issue and has to do with the code.   I'm not sure why the debugger isn't showing any of my DEBUG statements?





Jeff Haas

It is a code issue - you have commands in the code above that are for the AP-8, not the AP-16.  Look through your files and see if you have the right version.

This line is for the AP-8:

Power_Up:
  SEROUT Sio, OT2400, ("!!!!!AP8",%11,"X","!DC16",%11,"X")

This is from the AP-16 docs to reset the AP-16:

SEROUT Sio, OT2400, ("!AP16", %00, "X")
So look for code that has "!AP-16" in it.

davisgraveyard

After I replied I realized what you were saying.  The code I posted was the only backup I could find and it was very old.   I was sure I had edited it for the trigger but must have also updated to the AP16 to.  I made the changes and now the code runs sort of.  The audio player works and it falls through the code. But the DC16 was not driving the solenoid.  Looks like I moved it from the Prop1 Pin1 to the DC16 Pin 9.   But now I have to do a SEROUT command to the DC16 to trigger the solenoid.   Here is the final working code.



' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Solenoid        = 1


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IS_ON           = 1                     ' for active-high in/out
SYMBOL  IS_OFF          = 0
SYMBOL  Baud            = OT2400


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

SYMBOL  timer           = B2
SYMBOL  i               = B3


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs

  PAUSE 10                                      ' reset devices
  SEROUT Sio, Baud, ("!AP16", %11,"X")
  PAUSE 10
  SEROUT Sio, Baud, ("!DC16",%11,"X")


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

Main:
  timer = 0                                     ' reset timer

Get_Trigger_1:
  PAUSE 5
                                          ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 50 THEN Get_Trigger_1              ' 50ms for valid input


Force_Release:
  timer = 100                                   ' set 100ms release timer

Get_Trigger_0:
  PAUSE 5
  IF Trigger = IS_ON THEN Force_Release
    timer = timer - 5
    IF timer > 0 THEN Get_Trigger_0

Make_Sounds:
  FOR i = 1 TO 7
    SEROUT Sio, Baud, ("!AP16", %11, "PS", 1)
    PAUSE 1000
  NEXT

Light_Steps:
  FOR i = 0 TO 6
    PAUSE 5
    SEROUT Sio, Baud, ("!AP16",  %11, "PS", 1)
    PAUSE 5
    SEROUT Sio, Baud, ("!DC16", %11, "P", i, 1)
    PAUSE 1000
    SEROUT Sio, Baud, ("!DC16", %11, "P", i, 0)
  NEXT

  PAUSE 1000

Rattle_Solenoid:
  SEROUT Sio, Baud, ("!DC16", %11, "P",9, 1)
  PAUSE 10000
  SEROUT Sio, Baud, ("!DC16", %11, "P",9, 0)
  PAUSE 100

  GOTO Main

Jeff Haas

So you fixed it?  Great!  Glad it worked out.