hi...
i have a problem with "Write PI Command".
i write the Pterm, Iterm and Pscalar with value : 100, 20, 14
when i write it into EEprom it's succesful,
but after i power off the power and i try again to read PI,
the value back to the default,
pterm = 100
iterm = 20
skalar = 14
I'am using Basic stamp BS2P40
any one can help me?
Page 1 of 1
Write PI cannot saved into EEPROM Ask write PI
#3
Posted 03 June 2010 - 06:21 PM
this is my code:
'-----------------------------------------------
'{$stamp BS2P}
'{$PBasic 2.5}
baud con 1021
motorkananin con 5
motorkananout con 7
motorkiriin con 1
motorkiriout con 3
'-------------------------
ptermkanan var byte
itermkanan var byte
skalarkanan var byte
ptermkiri var byte
itermkiri var byte
skalarkiri var byte
ptermkanan = 100
itermkanan = 20
skalarkanan =14
serout motorkananout,baud,[Ptermkanan,itermkanan,skalarkanan]
ptermkiri = 100
itermkiri = 20
skalarkiri = 14
serout motorkiriout,baud,[Ptermkiri,itermkiri,skalarkiri]
end
'-----------------------------------------------
thank's
'-----------------------------------------------
'{$stamp BS2P}
'{$PBasic 2.5}
baud con 1021
motorkananin con 5
motorkananout con 7
motorkiriin con 1
motorkiriout con 3
'-------------------------
ptermkanan var byte
itermkanan var byte
skalarkanan var byte
ptermkiri var byte
itermkiri var byte
skalarkiri var byte
ptermkanan = 100
itermkanan = 20
skalarkanan =14
serout motorkananout,baud,[Ptermkanan,itermkanan,skalarkanan]
ptermkiri = 100
itermkiri = 20
skalarkiri = 14
serout motorkiriout,baud,[Ptermkiri,itermkiri,skalarkiri]
end
'-----------------------------------------------
thank's
#4
Posted 03 June 2010 - 07:26 PM
i'm sorry, my previous code not correct
this is the correct program code :
'{$STAMP BS2p}
BAUD CON 1021
motorkiriin CON 1 '>
motorkiriout CON 3 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananin CON 5 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananout CON 7 '>
PTERM VAR Byte 'Proportional constant term
ITERM VAR Byte 'Intergal constant term
SCALAR VAR Byte 'Magnitude of PI scalar
PTERMKANAN VAR Byte 'Proportional constant term
ITERMKANAN VAR Byte 'Intergal constant term
SCALARKANAN VAR Byte 'Magnitude of PI scalar
PTERMKANAN = 64
ITERMKANAN = 1
SCALARKANAN = 14
SEROUT motorkananout,BAUD,[$55,$10,PTERMKANAN,ITERMKANAN,SCALARKANAN] 'Write PI variables to EEPROM
PTERM = 64 '100
ITERM = 1 '5
SCALAR = 14 ' 100
SEROUT motorkiriout,BAUD,[$55,$10,PTERM,ITERM,SCALAR] 'Write PI variables to EEPROM
END
this is the correct program code :
'{$STAMP BS2p}
BAUD CON 1021
motorkiriin CON 1 '>
motorkiriout CON 3 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananin CON 5 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananout CON 7 '>
PTERM VAR Byte 'Proportional constant term
ITERM VAR Byte 'Intergal constant term
SCALAR VAR Byte 'Magnitude of PI scalar
PTERMKANAN VAR Byte 'Proportional constant term
ITERMKANAN VAR Byte 'Intergal constant term
SCALARKANAN VAR Byte 'Magnitude of PI scalar
PTERMKANAN = 64
ITERMKANAN = 1
SCALARKANAN = 14
SEROUT motorkananout,BAUD,[$55,$10,PTERMKANAN,ITERMKANAN,SCALARKANAN] 'Write PI variables to EEPROM
PTERM = 64 '100
ITERM = 1 '5
SCALAR = 14 ' 100
SEROUT motorkiriout,BAUD,[$55,$10,PTERM,ITERM,SCALAR] 'Write PI variables to EEPROM
END
#5
Posted 07 June 2010 - 12:47 PM
Your code looks okay. I don't see anywhere that you check to see that the terms are actually being read back. You might consider adding a READ PI command after one of the write commands, and using the Stamp DEBUG command to display the data. How do you know the PI commands are not being written?
Lon
Lon
#6
Posted 01 July 2010 - 11:25 PM
I have two programs to write to the EEPROM and to read the results,
This is a program to write EEPROM :
'{$STAMP BS2p}
'AN-263 Device = MMBe:
'This application note can be used to test PI or inc/dec modes
'of SPDCON in the MMBe. Commands assocaited with programming the PTERM,
'ITERM, and PISCALAR are implemented.
'
'TM CON 10 'Data to Stamp, select pin appropriate to your hardware (motorkiriin)
'FM CON 11 'Data sent by Stamp, select pin appropriate to your hardware (motorkiriout)
'TMKANAN CON 12 'Data to Stamp, select pin appropriate to your hardware (motorkananin)
'FMKANAN CON 13 '(motorkananout)
BAUD CON 240'1021
motorkiriin CON 1 '>
motorkiriout CON 3 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananin CON 5 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananout CON 7 '>
PTERM VAR Byte 'Proportional constant term
ITERM VAR Byte 'Intergal constant term
SCALAR VAR Byte 'Magnitude of PI scalar
PTERMKANAN VAR Byte 'Proportional constant term
ITERMKANAN VAR Byte 'Intergal constant term
SCALARKANAN VAR Byte 'Magnitude of PI scalar
PTERMKANAN = 100
ITERMKANAN = 5'1
SCALARKANAN = 14
SEROUT motorkananout,BAUD,[$55,$10,PTERMKANAN,ITERMKANAN,SCALARKANAN] 'Write PI variables to EEPROM
PTERM = 100
ITERM = 5
SCALAR = 14
SEROUT motorkiriout,BAUD,[$55,$10,PTERM,ITERM,SCALAR] 'Write PI variables to EEPROM
END
and This is a program to read EEPROM :
' {$STAMP BS2p}
' {$PBASIC 2.5}
'================================================================
' MOTOR
'================================================================
motorkiriin PIN 1 '>
motorkiriout PIN 3 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananin PIN 5 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananout PIN 7 '>
'==============================================================
' VARIABEL-VARIABEL
'==============================================================
i VAR Byte
status VAR Byte
dummy VAR Byte
BAUD CON 240
pimode VAR status.BIT5
freqlow VAR status.BIT4
baudrate VAR status.BIT3
PTERMKANAN VAR Byte
ITERMKANAN VAR Byte
SCALARKANAN VAR Byte
PTERM VAR Byte
ITERM VAR Byte
SCALAR VAR Byte
GOSUB cekpi
GOSUB cekfrek
GOSUB baudrate3
GOSUB mode
END
'==============================================================
' CEK PIMODE
'=============================================================
cekpi:
SEROUT motorkananout,BAUD,[$55,$05]
SERIN motorkananin,BAUD,[STATUS,DUMMY]
IF PIMODE = 1 THEN
DEBUG "kanan = pimode",CR
ELSE
DEBUG "kanan = inc/dec",CR
ENDIF
SEROUT motorkiriout,BAUD,[$55,$05]
SERIN motorkiriin,BAUD,[STATUS,DUMMY]
IF PIMODE = 1 THEN
DEBUG "kiri = pimode",CR
ELSE
DEBUG "kiri = inc/dec",CR
ENDIF
RETURN
'==============================================================
' CEK freqlow
'=============================================================
cekfrek:
SEROUT motorkananout,BAUD,[$55,$05]
SERIN motorkananin,BAUD,[STATUS,DUMMY]
IF freqlow = 1 THEN
DEBUG "frekanan = 242Hz",CR
ELSE
DEBUG "frekanan = 15Khz",CR
ENDIF
SEROUT motorkiriout,BAUD,[$55,$05]
SERIN motorkiriin,BAUD,[STATUS,DUMMY]
IF freqlow = 1 THEN
DEBUG "frekiri = 242Hz",CR
ELSE
DEBUG "frekiri = 15Khz",CR
ENDIF
RETURN
'==============================================================
' CEK BAUDRATE
'=============================================================
baudrate3:
SEROUT motorkananout,BAUD,[$55,$05]
SERIN motorkananin,BAUD,[STATUS,DUMMY]
IF baudrate = 1 THEN
DEBUG "baudkanan = 9600/240",CR
ELSE
DEBUG "baudkanan = 2400/1021",CR
ENDIF
SEROUT motorkiriout,BAUD,[$55,$05]
SERIN motorkiriin,BAUD,[STATUS,DUMMY]
IF baudrate = 1 THEN
DEBUG "baudkiri = 9600/240",CR
ELSE
DEBUG "baudkiri = 2400/1021",CR
ENDIF
RETURN
mode:
SEROUT motorkananout,BAUD,[$55,15] 'Send Read PI variable command
SERIN motorkananin,BAUD,[PTERMKANAN,ITERMKANAN,SCALARKANAN] 'receive PI variables
SEROUT motorkiriout,BAUD,[$55,15] 'Send Read PI variable command
SERIN motorkiriin,BAUD,[PTERM,ITERM,SCALAR] 'receive PI variables
DEBUG ? PTERMKANAN
DEBUG ? ITERMKANAN
DEBUG ? SCALARKANAN
DEBUG ? PTERM
DEBUG ? ITERM
DEBUG ? SCALAR
RETURN
thank's
This is a program to write EEPROM :
'{$STAMP BS2p}
'AN-263 Device = MMBe:
'This application note can be used to test PI or inc/dec modes
'of SPDCON in the MMBe. Commands assocaited with programming the PTERM,
'ITERM, and PISCALAR are implemented.
'
'TM CON 10 'Data to Stamp, select pin appropriate to your hardware (motorkiriin)
'FM CON 11 'Data sent by Stamp, select pin appropriate to your hardware (motorkiriout)
'TMKANAN CON 12 'Data to Stamp, select pin appropriate to your hardware (motorkananin)
'FMKANAN CON 13 '(motorkananout)
BAUD CON 240'1021
motorkiriin CON 1 '>
motorkiriout CON 3 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananin CON 5 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananout CON 7 '>
PTERM VAR Byte 'Proportional constant term
ITERM VAR Byte 'Intergal constant term
SCALAR VAR Byte 'Magnitude of PI scalar
PTERMKANAN VAR Byte 'Proportional constant term
ITERMKANAN VAR Byte 'Intergal constant term
SCALARKANAN VAR Byte 'Magnitude of PI scalar
PTERMKANAN = 100
ITERMKANAN = 5'1
SCALARKANAN = 14
SEROUT motorkananout,BAUD,[$55,$10,PTERMKANAN,ITERMKANAN,SCALARKANAN] 'Write PI variables to EEPROM
PTERM = 100
ITERM = 5
SCALAR = 14
SEROUT motorkiriout,BAUD,[$55,$10,PTERM,ITERM,SCALAR] 'Write PI variables to EEPROM
END
and This is a program to read EEPROM :
' {$STAMP BS2p}
' {$PBASIC 2.5}
'================================================================
' MOTOR
'================================================================
motorkiriin PIN 1 '>
motorkiriout PIN 3 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananin PIN 5 '> ' }} jalur komunikasi serial BS2p (main) to MMBe
motorkananout PIN 7 '>
'==============================================================
' VARIABEL-VARIABEL
'==============================================================
i VAR Byte
status VAR Byte
dummy VAR Byte
BAUD CON 240
pimode VAR status.BIT5
freqlow VAR status.BIT4
baudrate VAR status.BIT3
PTERMKANAN VAR Byte
ITERMKANAN VAR Byte
SCALARKANAN VAR Byte
PTERM VAR Byte
ITERM VAR Byte
SCALAR VAR Byte
GOSUB cekpi
GOSUB cekfrek
GOSUB baudrate3
GOSUB mode
END
'==============================================================
' CEK PIMODE
'=============================================================
cekpi:
SEROUT motorkananout,BAUD,[$55,$05]
SERIN motorkananin,BAUD,[STATUS,DUMMY]
IF PIMODE = 1 THEN
DEBUG "kanan = pimode",CR
ELSE
DEBUG "kanan = inc/dec",CR
ENDIF
SEROUT motorkiriout,BAUD,[$55,$05]
SERIN motorkiriin,BAUD,[STATUS,DUMMY]
IF PIMODE = 1 THEN
DEBUG "kiri = pimode",CR
ELSE
DEBUG "kiri = inc/dec",CR
ENDIF
RETURN
'==============================================================
' CEK freqlow
'=============================================================
cekfrek:
SEROUT motorkananout,BAUD,[$55,$05]
SERIN motorkananin,BAUD,[STATUS,DUMMY]
IF freqlow = 1 THEN
DEBUG "frekanan = 242Hz",CR
ELSE
DEBUG "frekanan = 15Khz",CR
ENDIF
SEROUT motorkiriout,BAUD,[$55,$05]
SERIN motorkiriin,BAUD,[STATUS,DUMMY]
IF freqlow = 1 THEN
DEBUG "frekiri = 242Hz",CR
ELSE
DEBUG "frekiri = 15Khz",CR
ENDIF
RETURN
'==============================================================
' CEK BAUDRATE
'=============================================================
baudrate3:
SEROUT motorkananout,BAUD,[$55,$05]
SERIN motorkananin,BAUD,[STATUS,DUMMY]
IF baudrate = 1 THEN
DEBUG "baudkanan = 9600/240",CR
ELSE
DEBUG "baudkanan = 2400/1021",CR
ENDIF
SEROUT motorkiriout,BAUD,[$55,$05]
SERIN motorkiriin,BAUD,[STATUS,DUMMY]
IF baudrate = 1 THEN
DEBUG "baudkiri = 9600/240",CR
ELSE
DEBUG "baudkiri = 2400/1021",CR
ENDIF
RETURN
mode:
SEROUT motorkananout,BAUD,[$55,15] 'Send Read PI variable command
SERIN motorkananin,BAUD,[PTERMKANAN,ITERMKANAN,SCALARKANAN] 'receive PI variables
SEROUT motorkiriout,BAUD,[$55,15] 'Send Read PI variable command
SERIN motorkiriin,BAUD,[PTERM,ITERM,SCALAR] 'receive PI variables
DEBUG ? PTERMKANAN
DEBUG ? ITERMKANAN
DEBUG ? SCALARKANAN
DEBUG ? PTERM
DEBUG ? ITERM
DEBUG ? SCALAR
RETURN
thank's
#7
Posted 03 July 2010 - 12:40 AM
first i write the MMBE with first program (program to write eeprom)
and then i read mmbe with second program (program to read EEPROM)
it's no problem, the result of Pterm, Iterm and scalar is same as written,
example:
i write to eeprom:
PTERM = 60
ITERM = 20
SCALAR = 10
the result after read :
PTERM = 60
ITERM = 20
SCALAR = 10
but when i turn off the power (MMBE & stamp), then i turn it on again,
and then i read it, the result of Pterm, Iterm and scalar back to default values
this is the result :
PTERM = 100
ITERM = 4
SCALAR = 10
are the values of Pterm, Iterm and scalar not written into EEPROM?,
or there's something wrong with my program?
and then i read mmbe with second program (program to read EEPROM)
it's no problem, the result of Pterm, Iterm and scalar is same as written,
example:
i write to eeprom:
PTERM = 60
ITERM = 20
SCALAR = 10
the result after read :
PTERM = 60
ITERM = 20
SCALAR = 10
but when i turn off the power (MMBE & stamp), then i turn it on again,
and then i read it, the result of Pterm, Iterm and scalar back to default values
this is the result :
PTERM = 100
ITERM = 4
SCALAR = 10
are the values of Pterm, Iterm and scalar not written into EEPROM?,
or there's something wrong with my program?
#8
Posted 19 July 2010 - 11:41 AM
I have to apologize. I thought I reviewed the firmware for this issue before I asked to see your code. When I set up a test code for the BS2 and ran it I saw the same problem you've described. I went back to the MMBe firmware and double checked the WRITE_PI function, and it does not try to write the data to EEPROM.
You could create a work-around by writing/reading the PI data to EEPROM using the WRITE_EEPROM/READ_EEPROM commands (example below). The simpler alternative it to execute a WRITE_PI as part of your start up routine that loads the values you want into the MMBe.
Example of using the EEPROM commands to store the PI values:
' {$STAMP BS2}
' {$PORT COM3}
'
TM CON 15
FM CON 14
RELAY CON 12
'
PTerm VAR Byte
ITerm VAR Byte
PIScalar VAR Byte
EERegister VAR Byte
EEAddress VAR Byte
Baud CON 396
START:
OUTS = %0000111000000000
DIRS = %0111101000111111
READY:
HIGH FM
PAUSE 250
'Write PI Data to EEPROM, PTerm, then ITerm, then PIScalar
EERegister = 200
EEAddress = 10
SEROUT FM,Baud,[$55,$09,EEAddress,EERegister]
EERegister = 10
EEAddress = EEAddress+1
SEROUT FM,Baud,[$55,$09,EEAddress,EERegister]
EERegister = 14
EEAddress = EEAddress+1
SEROUT FM,Baud,[$55,$09,EEAddress,EERegister]
'Read PI Data from EEPROM, PTerm, then ITerm, then PIScalar
EEAddress = 10
SEROUT FM,Baud,[$55,$0A,EEAddress]
SERIN TM,Baud,[PTerm]
EEAddress = EEAddress+1
SEROUT FM,Baud,[$55,$0A,EEAddress]
SERIN TM,Baud,[ITerm]
EEAddress = EEAddress+1
SEROUT FM,Baud,[$55,$0A,EEAddress]
SERIN TM,Baud,[PIScalar]
'Write EEPROM received data to the MMBe PI registers
SEROUT FM,Baud,[$55,$10,PTerm,ITerm,PIScalar]
END:
I will update the datasheet to reflect the fact that the WRITE_PI routine does not store the data in EEPROM.
Lon
You could create a work-around by writing/reading the PI data to EEPROM using the WRITE_EEPROM/READ_EEPROM commands (example below). The simpler alternative it to execute a WRITE_PI as part of your start up routine that loads the values you want into the MMBe.
Example of using the EEPROM commands to store the PI values:
' {$STAMP BS2}
' {$PORT COM3}
'
TM CON 15
FM CON 14
RELAY CON 12
'
PTerm VAR Byte
ITerm VAR Byte
PIScalar VAR Byte
EERegister VAR Byte
EEAddress VAR Byte
Baud CON 396
START:
OUTS = %0000111000000000
DIRS = %0111101000111111
READY:
HIGH FM
PAUSE 250
'Write PI Data to EEPROM, PTerm, then ITerm, then PIScalar
EERegister = 200
EEAddress = 10
SEROUT FM,Baud,[$55,$09,EEAddress,EERegister]
EERegister = 10
EEAddress = EEAddress+1
SEROUT FM,Baud,[$55,$09,EEAddress,EERegister]
EERegister = 14
EEAddress = EEAddress+1
SEROUT FM,Baud,[$55,$09,EEAddress,EERegister]
'Read PI Data from EEPROM, PTerm, then ITerm, then PIScalar
EEAddress = 10
SEROUT FM,Baud,[$55,$0A,EEAddress]
SERIN TM,Baud,[PTerm]
EEAddress = EEAddress+1
SEROUT FM,Baud,[$55,$0A,EEAddress]
SERIN TM,Baud,[ITerm]
EEAddress = EEAddress+1
SEROUT FM,Baud,[$55,$0A,EEAddress]
SERIN TM,Baud,[PIScalar]
'Write EEPROM received data to the MMBe PI registers
SEROUT FM,Baud,[$55,$10,PTerm,ITerm,PIScalar]
END:
I will update the datasheet to reflect the fact that the WRITE_PI routine does not store the data in EEPROM.
Lon
Share this topic:
Page 1 of 1

Help










