I apologize if the photo is somewhat misleading. The VMusic2 and VMusic3 are the same size. I think they used the same enclosure for all three versions. The unit on the left is a VDrive3. Since Parallax no longer sells the Datalogger I am going to look into its use as a replacement.
I try this to commands and nothing happens. Please see attachment guys for the serial commands on our mp3 module. Can you guys give us an idea on how we send this commands in basic stamp 2? THANKS!
That command is “specify play 255 songs in each folder”. It may not perform an external function, or there may be some setup functions that need to be done first. Unfortunately the description of the functions is somewhere between extremely poor and totally useless.
Do you have the speaker connected and an sd card with mp3’s inserted in the CY ? If so you may want to try some of the simpler commands like 11 - “repeat play all”.
Yes there is a speaker and sd card connected in our mp3 module. How do I send that command to basic stamp 2? Can you give me an example so i'll have an idea on how to send the command using basic stamp to our mp3 module.
The data sheet is missing a lot of information on this module, and some of what is there may be wrong. That means you will have to do a lot of experimenting to get it working. I am willing to help out as much as I can, but I do not have a CY module or a basic stamp to test with so there is a limit to how much help I can provide. I am going to go through the C program on the data sheet to see if I can figure out some of the missing information. In the meantime, do you have a scope so you can verify that serial data is going from the BS2 to the CY, and feedback data is being sent back from the CY to the BS2?
OK, had some time to look at the C code on the data sheet and it looks like the format is the same as what you are outputting with the Basic serout statements. I suspect that there need to be some setup commands before you can play any of the MP3 files. At the very least I think you would have to:
Once that is done you might be able to play some music.
I would suggest the following to simplify testing:
1- Set up a buffer “cmd_buf[10]” that will hold the commands to be sent out to the CY chip
2- Set up a table of the needed commands with the command, feedback, para1, para2 as the columns in the table
3- Initialize the buffer by copying “$7E,$FF,$06,$11,$00,$00,$01,$FE,$E9,$EF” to it
4- Input a character from the PC (0-9, a-z) to select a command
5- Use a case statement to select the command and copy the 4 bytes from the table to the command buffer
6- Calculate the checksum on bytes cmd_buf[1]..[6]
7- Send the 10 bytes in the buffer to the CY chip
Put this in a repeat loop so you can send as many commands as you want. It is a bit of coding to do, but it will make testing faster and easier, and most of the code can be re-used in the final software.
In any case I think just outputting the repeat play command is not enough. The CY chip probably needs to be initialized and set up before commands like repeat play will work.
Is there any way you can capture the data the pic chip outputs to the CY on power up? Perhaps connecting a usb to serial adapter to the PC and running a terminal program?
In any case I think just outputting the repeat play command is not enough. The CY chip probably needs to be initialized and set up before commands like repeat play will work.
Is there any way you can capture the data the pic chip outputs to the CY on power up? Perhaps connecting a usb to serial adapter to the PC and running a terminal program?
thanks kwinn, my pin 19 of bs2 is connected to pin2 of CY and pin20 of bs2 is connected to pin3 of CY. i`ve tried ur command but sadly to say it didnt work.
All of your SEROUTs need to use 14, not 19, since 19 is the physical pin but 14 is the actual pin name.
Look at Page 415 of the BS2 Manual for the SEROUT command [Page 419 of the PDF]
Note that SOUT (Pin 1) is TPin 16 so SEROUT 16 functions the same a DEBUG because SOUT is used for programming the BS2 so it's connected to the PC serial port.
Just remember that whenever we talk about BS2 pins we usually the pin name and not the physical pin number.
Are you using the BS2 on a breadboard, and if so how are you programming and powering it?
SEROUT 16,84,[$7E,$FF,$06,$11,$00,$00,$01,$FE,$E9,$EF] ' Repeat play all (Send to DEBUG Terminal)
' SEROUT TransmitPin, BaudMode, [OutputData]
' 84 = 8-Bit, No Parity, True = T9600 = True (Always Driven), N8, noninverted
' SOUT pin (physical pin 1) when Tpin = 16
' Format: $S VER Len CMD Feedback para1 para2 checksum $O
' $S = Start bit 0x7E - Each command feedback begin with $, that is 0x7E
' VER = Version - Version Information
' Len = the number of bytes after “Len” - Checksums are not counted
' CMD = Commands - Indicate the specific operations, such as play / pause, etc.
' Feedback = Command feedback - 1 :need feedback, 0: no need feedback
' para1 = Parameter 1 - Query high data byte
' para2 = Parameter 2 - Query low data byte
' checksum = Checksum - Accumulation and verification [not include start bit $]
' $O = End bit - End bit 0xEF
SEROUT 14,84,[$7E,$FF,$06,$11,$00,$00,$01,$FE,$E9,$EF] ' Repeat play all (P14 - Pin 19 to RX - Pin 2)
' SEROUT TransmitPin, BaudMode, [OutputData]
' 84 = 8-Bit, No Parity, True = T9600 = True (Always Driven), N8, noninverted
' Start bit, Version, Length = 6, Command = 11, Feedback = 0, Parameter 1 = 0, Parameter 2 = 1, Checksum = FF E6
' Start Bit = $7E
' Version = $FF
' Length = $06 = 6 Bytes, After Length but excluding checksum
' CMD = $11 = Repeat play all - Parameter = 1 to Start, 0 to Stop
' Parameter 1 = 0, Parameter 2 = Start (1) or Stop (0)
' Feedback = $00 = Don't need feedback
' Parameters: High = $00, Low = $01 ---> 1 to Start
' $FE = Upper Byte of Checksum (2's Complement)
' $E9 = Lower Byte of Checksum
' FF + 06 + 11 + 00 + 00 + 01 = $117 ---> $FEE9
' End Bit = $EF
Hi Genetix thanks for your reply and now it works. I have a question. How did you get the upper and lower byte of checksum by adding this ' FF + 06 + 11 + 00 + 00 + 01 = $117 ---> $FEE9 and how did you convert it into hexadecimal? THANKS!
Hi Genetix thanks for your reply and now it works. I have a question. How did you get the upper and lower byte of checksum by adding this ' FF + 06 + 11 + 00 + 00 + 01 = $117 ---> $FEE9 and how did you convert it into hexadecimal? THANKS!
Jon Mcphalen (Jonnymac) has done quite a bit of programming for the Vmusic2 player (though he doesn't like it one little bit, lol) using basic stamps. It might help you out.
Checksum:
Start with zero in a variable (16 bits in this case). Subtract each byte that's included in the checksum from the variable. When all the bytes are processed, you have the checksum. In this case, the bytes to be included are the version, length, cmd, feedback, parameter (upper byte then lower byte). The checksum is sent upper byte first then lower byte. The "start bit" and "end bit" are not included in the checksum.
Other devices may have very different checksum schemes.
The datasheet for the CY-T16 is missing a lot of details but luckily there is a sample C program.
I don't know if you know C but look at DoSum.
XorSum starts at 0 and then each data Byte is added to it.
I used the Windows Calculator but the BS2 should not have a problem if you use a WORD or 16-bit variable.
Next, this sum needs to be converted to what's called the "Two's Complement" or the Additive Inverse in Binary (Base 2) notation.
On a calculator if you press the +/- key, it will turn a number from a positive to a negative but another way to do this is in binary.
$117 is 0000-0001 0001-0111 in binary.
To convert to 2's-Complete, we invert or "flip" all the bits (0 becomes 1 and 1 becomes 0) and then add 1.
Inverting 0000-0001 0001-0111 it becomes 1111-1110 1110-1000. (Notice all the bits have been flipped)
Now add 1 to 1111-1110 1110-1000 to get 1111-1110 1110-1001. (See the 1 in the rightmost place)
Now converting back to hex it becomes $FEE9.
Notice that if we add $0117 to $FEE9 the result is $10000, but since these are 16-bit numbers the 1 is not seen.
It's the same as if you add a number to it's negative, the result is 0.
Thanks guys i've understand on how to convert 117 to FEE9. Now my problem is how to subtract all hexadecimal numbers, can you give me an example or easiest way to subtract hexadecimal numbers. thanks guys!!!!
I need to see an example solution for computing/subtracting the hexadecimal, so i can understand it more clearly. Thanks Guys!
What you need to do is set a 16 bit binary number to zero and then subtract each of the six 8 bit binary values from the 16 bit number. Hex values are just a way of making binary numbers easier for humans to work with. FFE9 is easier for us to work with than 1111111111101001 even though they are the same value.
thanks for the reply guys really appreciated. Now our next step is on how the basic stamp receive a schedule. its like an PA system. On our previous PIC. we use vb program to send and sync a schedule in able for the device to output a sound in a given schedule. Does anyone here has an experience on sending alarm schedule to BASIC STAMP? thanks!
Comments
I like the compactness of the VMUSIC2.
When posting code, please use the "C" in the editor to paste your code. This will preserve your indentations in the code.
I try this to commands and nothing happens. Please see attachment guys for the serial commands on our mp3 module. Can you guys give us an idea on how we send this commands in basic stamp 2? THANKS!
Do you have the speaker connected and an sd card with mp3’s inserted in the CY ? If so you may want to try some of the simpler commands like 11 - “repeat play all”.
SEROUT16,84,[$7E,$FF,$06,$11,$00,$00,$01,$FE,$E9,$EF]
The data sheet is missing a lot of information on this module, and some of what is there may be wrong. That means you will have to do a lot of experimenting to get it working. I am willing to help out as much as I can, but I do not have a CY module or a basic stamp to test with so there is a limit to how much help I can provide. I am going to go through the C program on the data sheet to see if I can figure out some of the missing information. In the meantime, do you have a scope so you can verify that serial data is going from the BS2 to the CY, and feedback data is being sent back from the CY to the BS2?
Reset the module – 0x0C
Send initialization parameters - 0x3F
Specify playback source – 0x09
Specify volume – 0x06
Once that is done you might be able to play some music.
I would suggest the following to simplify testing:
1- Set up a buffer “cmd_buf[10]” that will hold the commands to be sent out to the CY chip
2- Set up a table of the needed commands with the command, feedback, para1, para2 as the columns in the table
3- Initialize the buffer by copying “$7E,$FF,$06,$11,$00,$00,$01,$FE,$E9,$EF” to it
4- Input a character from the PC (0-9, a-z) to select a command
5- Use a case statement to select the command and copy the 4 bytes from the table to the command buffer
6- Calculate the checksum on bytes cmd_buf[1]..[6]
7- Send the 10 bytes in the buffer to the CY chip
Put this in a repeat loop so you can send as many commands as you want. It is a bit of coding to do, but it will make testing faster and easier, and most of the code can be re-used in the final software.
' {$PBASIC 2.5}
SEROUT 19, 84, [$7E]
PAUSE 100
SEROUT 19, 84, [$FF]
PAUSE 100
SEROUT 19, 84, [$06]
PAUSE 100
SEROUT 19, 84, [$11]
PAUSE 100
SEROUT 19, 84, [$00]
PAUSE 100
SEROUT 19, 84, [$01]
PAUSE 100
SEROUT 19, 84, [$01]
PAUSE 100
SEROUT 19, 84, [$FE]
PAUSE 100
SEROUT 19, 84, [$E9]
PAUSE 100
SEROUT 19, 84, [$EF]
this is my code for sending mp3 command, is it correct or not? my RX is pin19 and my TX is pin20 of bs2
The command also has an error. See the bold text below.
It should be: $7E,$FF,$06,$11,$00,$00,$01,$FE,$E9,$EF
SEROUT 19, 84, [$7E]
PAUSE 100
SEROUT 19, 84, [$FF]
PAUSE 100
SEROUT 19, 84, [$06]
PAUSE 100
SEROUT 19, 84, [$11]
PAUSE 100
SEROUT 19, 84, [$00]
PAUSE 100
SEROUT 19, 84, [$01]
PAUSE 100
SEROUT 19, 84, [$01]
PAUSE 100
SEROUT 19, 84, [$FE]
PAUSE 100
SEROUT 19, 84, [$E9]
PAUSE 100
SEROUT 19, 84, [$EF]
Is there any way you can capture the data the pic chip outputs to the CY on power up? Perhaps connecting a usb to serial adapter to the PC and running a terminal program?
thanks kwinn, my pin 19 of bs2 is connected to pin2 of CY and pin20 of bs2 is connected to pin3 of CY. i`ve tried ur command but sadly to say it didnt work.
I am using Basic Stamp 2 rev. K
The BS2 has only 16 I/O called P0 to P15, and these are the pin names that PBASIC uses.
Look at page 13 of the BASIC Stamp Manual which has a nice diagram of the BS2.
https://www.parallax.com/sites/default/files/downloads/27218-Web-BASICStampManual-v2.2.pdf
Pin 20 is P15
Pin 19 is P14
So you have P14 connected to RX of the CY-T16 and P15 connected to TX.
All of your SEROUTs need to use 14, not 19, since 19 is the physical pin but 14 is the actual pin name.
Look at Page 415 of the BS2 Manual for the SEROUT command [Page 419 of the PDF]
Note that SOUT (Pin 1) is TPin 16 so SEROUT 16 functions the same a DEBUG because SOUT is used for programming the BS2 so it's connected to the PC serial port.
Just remember that whenever we talk about BS2 pins we usually the pin name and not the physical pin number.
Are you using the BS2 on a breadboard, and if so how are you programming and powering it?
16 bit Checksum = 0000
Checksum -FF -06 -11 -00 -00 -01= FEE9
http://www.efx-tek.com/php/smf/index.php?board=24.0
Jon Mcphalen (Jonnymac) has done quite a bit of programming for the Vmusic2 player (though he doesn't like it one little bit, lol) using basic stamps. It might help you out.
Start with zero in a variable (16 bits in this case). Subtract each byte that's included in the checksum from the variable. When all the bytes are processed, you have the checksum. In this case, the bytes to be included are the version, length, cmd, feedback, parameter (upper byte then lower byte). The checksum is sent upper byte first then lower byte. The "start bit" and "end bit" are not included in the checksum.
Other devices may have very different checksum schemes.
The datasheet for the CY-T16 is missing a lot of details but luckily there is a sample C program.
I don't know if you know C but look at DoSum.
XorSum starts at 0 and then each data Byte is added to it.
I used the Windows Calculator but the BS2 should not have a problem if you use a WORD or 16-bit variable.
Next, this sum needs to be converted to what's called the "Two's Complement" or the Additive Inverse in Binary (Base 2) notation.
On a calculator if you press the +/- key, it will turn a number from a positive to a negative but another way to do this is in binary.
$117 is 0000-0001 0001-0111 in binary.
To convert to 2's-Complete, we invert or "flip" all the bits (0 becomes 1 and 1 becomes 0) and then add 1.
Inverting 0000-0001 0001-0111 it becomes 1111-1110 1110-1000. (Notice all the bits have been flipped)
Now add 1 to 1111-1110 1110-1000 to get 1111-1110 1110-1001. (See the 1 in the rightmost place)
Now converting back to hex it becomes $FEE9.
Notice that if we add $0117 to $FEE9 the result is $10000, but since these are 16-bit numbers the 1 is not seen.
It's the same as if you add a number to it's negative, the result is 0.
What you need to do is set a 16 bit binary number to zero and then subtract each of the six 8 bit binary values from the 16 bit number. Hex values are just a way of making binary numbers easier for humans to work with. FFE9 is easier for us to work with than 1111111111101001 even though they are the same value.
checksum = $0 ‘ initialize 16 bit integer checksum to 0
checksum = checksum - $FF ‘ subtract first byte - checksum is now FF01
checksum = checksum - $06 ‘ subtract second byte – checksum = FEFB
checksum = checksum - $11 ‘ subtract third byte – checksum = FEEA
checksum = checksum - $00 ‘ subtract fourth byte – checksum = FEEA
checksum = checksum - $00 ‘ subtract fifth byte – checksum = FEEA
checksum = checksum - $01 ‘ subtract fourth byte – checksum = FEE9
Of course it is simpler to have the bytes in an array or string and then do the calculation in a loop.