pokoRanger
07-25-07, 10:15 PM
Hello.
I will apologize if this is a ridiculously naive question, but I have a question regarding controlling the frequency for the A/D using ISOMAX, specifically for the MINPOD. Right now, I have a microphone ready with the voltage confined in the range of .5 to 3.0V, and I would like to do A/D conversion for this. I am hoping I can perform the sampling at around 30kHz (ideally 40kHz), and according to the spec, MINPOD is capable of do continuous AD at 1.2us, roughly at 833khz. I first used machine language, using
EVERY 113 CYCLES SCHEDULE-RUNS ADC_BUTTON
\ 44.1KHZ=5MHZ/#CYCLES, CYCLES=5MHZ/44.1KHZ~=113CYCLES
I created a machine ADC_BUTTON which will start the ADC when a button is pressed. But with this code, the machine freezes up. I understand that this may be extremely simple thing, but I would deeply appreciate it if I could receive some guidance. Thank you.
Sincerely,
Suzuki Takafumi
\ following is the code I've tried...It's my first crack at FORTH and ISOMAX,
\ as it may be a poorly written code
HEX
: ON?
1 =
IF
2DUP 3 + @ SWAP FFFF XOR AND OVER 3 + !
2DUP 2 + @ SWAP FFFF XOR AND OVER 2 + !
1+ @ AND 0=
ELSE
SWAP DROP DUP @ FCFE AND OVER ! @ FF7F AND 0= NOT
THEN
;
: OFF?
1 =
IF
2DUP 3 + @ SWAP FFFF XOR AND OVER 3 + !
2DUP 2 + @ SWAP FFFF XOR AND OVER 2 + !
1+ @ AND 0=
ELSE
SWAP DROP DUP @ FCFE AND OVER ! @ FF7F AND 0=
THEN
;
DECIMAL
( Single Ended Voltage = Vref x [Value Read/32760] )
: DECIVAL S>F VREF FSWAP 32760.0e F/ F* F. ;
LOOPINDEX CYCLE-COUNTER
DECIMAL 1 CYCLE-COUNTER END
1 CYCLE-COUNTER START
MACHINE ADC_BUTTON
ON-MACHINE ADC_BUTTON
APPEND-STATE ADC_OFF
APPEND-STATE ADC_ON
\ perform AD and output voltage when PA is grounded
\ or when button is pressed
IN-STATE
ADC_OFF
CONDITION
PA7 OFF?
CAUSES
ADC0 ANALOGIN S>F 32760.0e F/ 3.30e F* F.
THEN-STATE
ADC_ON
TO-HAPPEN
\ stop AD and output voltage when PA is no longer grounded,
\ ie button is released
IN-STATE ADC_ON
CONDITION
PA7 ON?
CAUSES
PA7 ON?
THEN-STATE
ADC_OFF
TO-HAPPEN
\ continue AD and output voltage when PA is still grounded
\ or when button is still pressed
IN-STATE ADC_ON
CONDITION
CYCLE-COUNTER COUNT
CAUSES
." "
ADC0 ANALOGIN S>F 32760.0e F/ 3.30e F* F.
THEN-STATE
ADC_ON
TO-HAPPEN
ADC_OFF SET-STATE ( INSTALL ADC_BUTTON
EVERY 113CYCLES SCHEDULE-RUNS ADC_BUTTON
\ 50000CYCLES = 10MS/PERIOD = 100HZ
\ 5000CYCLES = 1MS/PERIOD = 1KHZ
\
\ (freq you want)=5MHZ/(#CYCLES)
\ CYCLES=5MHZ/(frequency you want)
\
\ 44.1KHZ=5MHZ/#CYCLES, CYCLES=5MHZ/44.1KHZ~=113CYCLES
I will apologize if this is a ridiculously naive question, but I have a question regarding controlling the frequency for the A/D using ISOMAX, specifically for the MINPOD. Right now, I have a microphone ready with the voltage confined in the range of .5 to 3.0V, and I would like to do A/D conversion for this. I am hoping I can perform the sampling at around 30kHz (ideally 40kHz), and according to the spec, MINPOD is capable of do continuous AD at 1.2us, roughly at 833khz. I first used machine language, using
EVERY 113 CYCLES SCHEDULE-RUNS ADC_BUTTON
\ 44.1KHZ=5MHZ/#CYCLES, CYCLES=5MHZ/44.1KHZ~=113CYCLES
I created a machine ADC_BUTTON which will start the ADC when a button is pressed. But with this code, the machine freezes up. I understand that this may be extremely simple thing, but I would deeply appreciate it if I could receive some guidance. Thank you.
Sincerely,
Suzuki Takafumi
\ following is the code I've tried...It's my first crack at FORTH and ISOMAX,
\ as it may be a poorly written code
HEX
: ON?
1 =
IF
2DUP 3 + @ SWAP FFFF XOR AND OVER 3 + !
2DUP 2 + @ SWAP FFFF XOR AND OVER 2 + !
1+ @ AND 0=
ELSE
SWAP DROP DUP @ FCFE AND OVER ! @ FF7F AND 0= NOT
THEN
;
: OFF?
1 =
IF
2DUP 3 + @ SWAP FFFF XOR AND OVER 3 + !
2DUP 2 + @ SWAP FFFF XOR AND OVER 2 + !
1+ @ AND 0=
ELSE
SWAP DROP DUP @ FCFE AND OVER ! @ FF7F AND 0=
THEN
;
DECIMAL
( Single Ended Voltage = Vref x [Value Read/32760] )
: DECIVAL S>F VREF FSWAP 32760.0e F/ F* F. ;
LOOPINDEX CYCLE-COUNTER
DECIMAL 1 CYCLE-COUNTER END
1 CYCLE-COUNTER START
MACHINE ADC_BUTTON
ON-MACHINE ADC_BUTTON
APPEND-STATE ADC_OFF
APPEND-STATE ADC_ON
\ perform AD and output voltage when PA is grounded
\ or when button is pressed
IN-STATE
ADC_OFF
CONDITION
PA7 OFF?
CAUSES
ADC0 ANALOGIN S>F 32760.0e F/ 3.30e F* F.
THEN-STATE
ADC_ON
TO-HAPPEN
\ stop AD and output voltage when PA is no longer grounded,
\ ie button is released
IN-STATE ADC_ON
CONDITION
PA7 ON?
CAUSES
PA7 ON?
THEN-STATE
ADC_OFF
TO-HAPPEN
\ continue AD and output voltage when PA is still grounded
\ or when button is still pressed
IN-STATE ADC_ON
CONDITION
CYCLE-COUNTER COUNT
CAUSES
." "
ADC0 ANALOGIN S>F 32760.0e F/ 3.30e F* F.
THEN-STATE
ADC_ON
TO-HAPPEN
ADC_OFF SET-STATE ( INSTALL ADC_BUTTON
EVERY 113CYCLES SCHEDULE-RUNS ADC_BUTTON
\ 50000CYCLES = 10MS/PERIOD = 100HZ
\ 5000CYCLES = 1MS/PERIOD = 1KHZ
\
\ (freq you want)=5MHZ/(#CYCLES)
\ CYCLES=5MHZ/(frequency you want)
\
\ 44.1KHZ=5MHZ/#CYCLES, CYCLES=5MHZ/44.1KHZ~=113CYCLES