MP3 Clone?

LouMar

Member
Thank you for that post but I have no idea what that code is or what to do with it. The photo looks like what I need in order to download a program into my 14M2. It looks a lot different from the diagram in the manual that I followed to make my device.

Is there anywhere I can buy one already assembled and modify the chip location so it can be installed on my breadboard? By having it on my breadboard, I don't have to remove and reinstall the 14M2 every time it may become necessary to change the program.
 
Last edited:

premelec

Senior Member
@LouMar - in post #18 you said you had an AXE117 project board - that's what you need to program the 14M2 - with an appropriate cable to connect to your computer running the PICAXE editor. The programming parts are just 2 resistors - however you have to have the right cable to your computer. You can make up your board with this programming setup easily enough - however I strongly suggest you become more familiar with simple programming before trying your more complicated project - hence the blinky LED exercise.

Have you ever gotten any program into the 14M2? There are many steps that have to be completed successfully - the parts of the program and the hardware don't put themselves together. Perhaps studying up on basic electronics will help also. If you can find someone in your area to work with that certainly would help however reading the manuals and trying simple programs will also do the trick.
 

AllyCat

Senior Member
Hi LouMar,

I think I've looked right through this thread, but can't find any reference to the type of Programming Cable being used. That must be the absolute starting point; do you have an AXE027 USB Programming cable, or what else are you trying to use?

Cheers, Alan.
 

LouMar

Member
Yes, I have a AXE027 USB Programming cable. I think this problem will be solved when I receive part I ordered this morning as recommended by Buzby. Thank you.
 

LouMar

Member
Buzby,
I ordered and just received the part (AXE029 Breadboard Adapter) you recommended. The datasheet says that the item can be used with an18 or 28/40 pin chip. It is also possible to use with an 8 pin chip with separate wires to the chip. I have a 14M2 chip but the datasheet does not have a 14M2 chip listed for use with this Adapter. Have you or anyone else used this with a 14M2 chip? I am going to use wires to my 14M2 as is necessary for the 8 pin chip.

The datasheet also says, "The board does not contain the PICAXE reset pull-up resistor (18/28/40) or external resonator (28/40). These must be added on the breadboard layout." Do I use a reset pull-up resistor, external resonator or both? If I need a resistor, what size resistor do I use and where do I connect it? If I need an external resonator, where do I get one and where/how do I install it?
 
Last edited:

AllyCat

Senior Member
Hi,

The 08M2, 14M2 and 20M2 all have the same arrangement of Programming (Downloading) and Power Supply pins at one end, so the adaptor can be used in the same way for all of them.

The 14M2 does not have an external reset pin, nor an external resonator facility, so you do not need those components.

Cheers, Alan.
 

LouMar

Member
Thank you that info. I assembled and connected the AXE029 Breadboard Adapter and downloaded the Blinking
light program. It took 3-4 times before the program downloaded but it eventually did and LED blinks.
 
Last edited:

LouMar

Member
Now I need help programming my WTV020-SD-16P Voice Module. I used the flowchart programming
method to write my program; however, there are no flowcharts to code a voice module.

I have 8 messages to play that are 'located' in 4 separate flowchart procedures. Some messages only play
once and stop. Some replay based on inputs that I have to test after a message is played. Some will play
until the power is turned off.

I think I may be able to use the following BASIC code to allow single or multiple plays by entering
the code at each location in a BASIC flowchart box. I think I used 'put' and 'get' correctly to pass and
receive variables. I know the PLAYER PROCEDURE needs work and I hope someone can help me with it. In a
previous post on page 2 of this thread, Hippy provided general code for control of a voice module for which
I am grateful; however, I am unable to figure out how to change it to make it do what I need. I hope he or
somebody can help.

Additionally, my project does not have an end. The program ends when the breadboard power is turned off from a
manual switch. The power may be turned off at any time during any function being executed. Does the program
automatically reset to the start position when power is turned on or do I need something to enable the program to
reset when power is turned back on? I want to start the program at the beginning and not just continue executing
at the place it was when the power was previously turned off. If something is needed, what do I do?

Code:
BASIC BOX IN FLOWCHART PROGRAM						
        b1 = 1                        ; play flag in put/get 1		
        b2 = (I enter volume number)  ; message volume from 1-7 in put/get 2		
        b3 = 1                        ; stop flag in put/get 3		
        w1 = (I enter message name)   ; message number (0000-0007) plus '.ad4' in put/get 4		
Voice:
        put 1, b1					
        put 2, b2					
        put 4, word w1					
        gosub Player					
        get 3, b3					
        if b3 = 1 then					
             (Based on 'location', I will enter a test that will yield b1 = 1 or b1 = 0)					
             goto Voice					
        endif	
				
 						
(My 14M2 output pins for the Voice Module are: RST = B.5, CLK = B.4, DAT = B.3)						
PLAYER PROCEDURE						
        get 1, b1					
        get 2, b2					
        get 4, word w1					
        if b1 = 1 then					
             volume = b2					
             Pause 2000					
             play w1					
             b3 = 1					
             put 3, b3					
             return					
        else					
             stop					
             reset Voice Module					
        endif					
        b3 = 0					
        put 3, b3					
        return
 

BeanieBots

Moderator
I'll leave it to others to answer your code questions, but as far as a power down is concerned. Whenever power is re-applied, the program will always start from the beginning of your code and all variable values will be reset to zero.
 

LouMar

Member
Thank you BeanieBots. That's one less problem I have to worry about.

I hope someone can answer my code questions before your last post.
 

hippy

Technical Support
Staff member
Code:
        put 1, b1					
        put 2, b2					
        put 4, word w1
You do not need to put variables into RAM when calling a routine, simply let the routine use the variables which holds the data. You would also have to be careful where you put variables into RAM.

Also be careful about variable overlap as word variables are formed from two byte variables. For this reason using 'b2' or 'b3' plus 'w1' is probably not what you want to do; altering 'w1' will alter b2 and b3, altering b2 or b3 will alter w1.
 

LouMar

Member
I think what you are saying that it is not necessary to use the put/get statement and just use the variables that have the data.

How do I pass the data from the variables created in the first routine and then receive them in the sub-routine? Also, how do I pass the data from the variables created in the sub-routine and receive them in the first routine?
 

hippy

Technical Support
Staff member
If you put data in a variable, either using a Basic cell or a flowchart expression cell, that variable and its value will simply be there when the subroutine wants to use it. And vice-versa.
 

LouMar

Member
Ok, thanks - that makes it easy.

Do you think my code (using it in 8 different locations) without the put/get will work for calling the sub-procedure? Can you please help with the sub-procedure code?
 

LouMar

Member
My computer can't open this file. I am worried about downloading software to open the file. A few weeks ago I downloaded a file to convert wma to wav to ad4. It cost me $178 and 4 days to repair the virus damage.
 
Last edited:

LouMar

Member
Thank you. I was able to open it. At this point, i don't fully understand it but during the next couple of days I will try to place it within my program and let you know if it works. Thanks again.
 

LouMar

Member
For hippy,

I am really sorry for bothering you again but I need help. I have tried but I am incapable of figuring out how to use your program to make all my files work. I rearranged my procedures to allow for each file to call PLAYER. I have player with one basic box and a return. All I need is the code to be placed in the basic box. I am not capable of picking the right code to go in the basic box. I coded flags to do what I need in the procedures I wrote; not very elaborate but they will work and I understand them. My project will be complete when this one basic box is complete.
 
Last edited:

LouMar

Member
I have previously posted the following. Maybe hippy or anyone else could open this Picaxe file and help. Thank you.

For hippy,

I am really sorry for bothering you again but I need help. I have tried but I am incapable of figuring out how to use your program to make all my files work. I rearranged my procedures to allow for each file to call PLAYER. I have player with one basic box and a return. All I need is the code to be placed in the basic box. I am not capable of picking the right code to go in the basic box. I coded flags to do what I need in the procedures I wrote; not very elaborate but they will work and I understand them. My project will be complete when this one basic box is complete.
 
Last edited:

hippy

Technical Support
Staff member
I have tried but I am incapable of figuring out how to use your program to make all my files work.
All you should need to do is set varA to the number of the track you want playing, call the TRACK routine, then call the PLAY routine.
 

LouMar

Member
Are you referring to the code you provided on page 2 of this thread or the code you later provided with the flowcharts? Either way, I can't understand your logic and don't know how to do what you said in your last post. I am very limited on what I can understand that's why I wrote the PLAYER routine the way I did. I just need the code to fit in before my two if statements and the code to fit in my two if statements plus code after the if statements if required.
 

LouMar

Member
Thank you for the suggestion but if I buy this, I will still have the problem of programing it. I don't know how to program.
 

LouMar

Member
I have 8 file-names that I need to store in a variable. I will use the same variable over and over again every time I need to change the file name. The file names are the same except for the last digit. For example, the first file name is < 0000.ad4 > and the last file name is < 0007.ad4 >. Will w0=0000.ad4 work? If not, will s_w0=0000.ad4 work? If neither will work, how do I do it?
 
Last edited:

rossko57

Senior Member
The way to approach it would be as two parts of a character string, with a variable digit in between
Principle:
"file000" + digit + ".ad4"
In a Picaxe program you might have a byte variable representing your digit, that you can manipulate in your program - increment it or whatever. Then translate that into one (or two I suppose) ASCII digits when you want to build the whole string and send it.
 

LouMar

Member
Thank you for your response. I am a beginner.
Is this what you mean? s_w0="000" + varI + ".ad4" or s_w0=000 + varI = ".ad4"
I don't know what or how to "Then translate that into one (or two I suppose) ASCII digits when you want to build the whole string and send it."
The variable I am creating is a file name on a microSD card that is inserted into a voice module. I am trying to use the variable to tell the voice module what file to play.
 
Last edited:

hippy

Technical Support
Staff member
I have 8 file-names that I need to store in a variable.
Not quite. You need to send a value to the module which indicates which filename the module will select. Send value zero and it will select the file named "0000.ad4", send value 1 and it will select the file named "0001.ad4", and so on up to sending value 511 to select file "0511.ad4".

If you want to select file "0001.ad4" then send value 1 to the module, if you want to select file "0008.ad4" then send value 8, etc.

The bigger problem though is that you appear to be out of your depth. It is quite an ambitious project to take on if you don't have the past experience to handle its complexities. Explaining what needs to be done won't help you any if you cannot understand the explanation and it's not at all easy to explain the complexities in a way which those without the experience can understand.

Unfortunately there is no shortcut to getting the level of experience required for a project without acquiring that level of experience by progressing through projects which are within levels of capabilities at their time.

I think the best course would be to reassess how you can pursue this project, consider what you need to do to become able to do it, rather than diving in at the deep end and hoping to be able to do it. That can turn out to be a frustrating experience as I imagine is the case here.
 

AllyCat

Senior Member
Hi LouMar,

Is this what you mean? s_w0="000" + varI + ".ad4" or s_w0=000 + varI = ".ad4"
No, you are trying to setup a "string variable" and PICaxe does not directly support string variables. Also forget about Words (for now). It may seem strange but "Words" are only intended to store larger numbers, so will not help with what you are trying to do.

I believe the data must be sent via an SPI bus, so you need to treat the string (i.e. the file name) as a "sequence of bytes", where each byte represents one character. Eventually, it will probably best be done by reading bytes from the EPROM inside the PICaxe, but for now consider the following to send the characters "FILE02" via a SPI bus (to the player):

Code:
b10 = "F"
b11 = "I"
b12 = "L"
b13 = "E"
b14 = "0"
b15 = "2"                        ; Main program can change this value
for b0 = 10 to 15             ; Loop to send character bytes in sequence
    peek b0,b1                 ; Read a character at the pointer (b0) into b1
    gosub send_byte_in_b1_via_spi
next b0
;  etc....

send_byte_in_b1_via_spi:          ; subroutine

        ; Lots of bit-bashing program code here

return
But this is not an easy project, perhaps not even practical using Logicator, so I'm afraid I must repeat IWPs prediction from post #4 :

Without figuring out the data sheet and also getting a working knowledge of the electronics and the PICAXE, you're going to really struggle. Perhaps you are starting with a project that is too difficult for a beginner. As much as forum members would like to help, it is your project and they can't make it for you.
Cheers, Alan.
 

LouMar

Member
Thank you AllyCat and hippy.
From the first code sent to me from hippy, I think I am pretty close. Does this look like it will work?
Code:
PowerOnReset:
High RST
High CLK
High DAT

If varK = 1 then
	w0 = varJ : Gosub SetVolume
	if varI=0 then
		w0=0000 : Gosub SetTrack
	End If
	if varI=1 then
		w0=0001 : Gosub SetTrack
	End If
	if varI=2 then
		w0=0002 : Gosub SetTrack
	End If
	if varI=3 then
		w0=0003 : Gosub SetTrack
	End If
	if varI=4 then
		w0=0004 : Gosub SetTrack
	End If
	if varI=5 then
		w0=0005 : Gosub SetTrack
	End If
	if varI=6 then
		w0=0006 : Gosub SetTrack
	End If
	if varI=7 then
		w0=0007 : Gosub SetTrack
	End If
	
	Gosub PlayTrack
	Pause 2000
				
	SetVolume:
	w0 = w0 | $FFF0
	Goto TransmitW0

	SetTrack:
	w0 = w0 & $01FF
	Goto TransmitW0

	PlayTrack:
	w0 = $FFFE
	Goto TransmitW0
End If

If varL = 1 then
	w0 = $FFFF
	Goto TransmitW0	
End If
Goto Back
	TransmitW0:
	Low RST
	Pause 5
	High RST
	Pause 300
	If w0 >= $8000 Then
		High DAT
	Else
		Low DAT
	End If
	Pause 2
	Low CLK
	PauseUs 20
	High CLK
	w0 = w0 * 2
	High DAT	
	return
Back:
 

hippy

Technical Support
Staff member
From the first code sent to me from hippy, I think I am pretty close. Does this look like it will work?
Possibly but it's incomplete code, hard to knowthe context it will be used in, so hard to tell. I am guessing you plan to drop this in some Basic block; if so, as it is presented, no it won't work -

After the "if varI=7 then ... end if" it falls into a "Gosub PlayTrack". Perhaps you just need to remove the extraneous code and add a "Goto Back" ?

But it does appear you are on the right track.
 

AllyCat

Senior Member
Hi,

Sorry, I still think there's quite some way to go. Firstly, it shouldn't need us to put the code into the Program Editor and find about half the lines fail syntax checking. Mainly due to missing detail, but not information that we (or at least I) can know.

Secondly, I don't see how that code follows on from the previous discussion of handling file names.

Thirdly, the TransmitW0 routine will not work because it has no loop structure to send the 16 individual bits of the word.

Cheers, Alan.
 

hippy

Technical Support
Staff member
This could be more like what you intended ...

Code:
Symbol RST = B.1
Symbol CLK = B.2
Symbol DAT = B.3

BasicCell:
  High RST
  High CLK
  High DAT
  If varK = 1 Then
    w0 = varJ
    Gosub SetVolume ; w0 = 0 to 7
    w0 = varI
    Gosub SetTrack  ; w0 = 0000 to 0511
    Gosub PlayTrack
  Else
    If varL = 1 Then
      Gosub StopTrack
    End If
  End If
  Goto Back

SetVolume:
  w0 = w0 | $FFF0
  Goto TransmitW0

SetTrack:
  w0 = w0 & $01FF
  Goto TransmitW0

PlayTrack:
PauseTrack:
UnPauseTrack:
  w0 = $FFFE
  Goto TransmitW0

StopTrack:
  w0 = $FFFF
  Goto TransmitW0

TransmitW0:
  Low RST
  Pause 5
  High RST
  Pause 300
  For b2 = 0 To 15
    If w0 >= $8000 Then
      High DAT
    Else
      Low  DAT
    End If
    Pause 2
    Low CLK
    PauseUs 20
    High CLK
    w0 = w0 * 2
  Next
  High DAT
  Return

Back:
That should work as code but whether it does what is intended or needed depends on how varI, varJ, varK and varL are controlled or manipulated within the flowchart program.
 

LouMar

Member
hippy,
Thank you very much for this code. Just a few clarifications questions.

1) I declared the 3 symbols in the main procedure. Is that okay or should I remove and place here as you show?
2) I have B.3 = DAT; B.4 = CLK; and B.5 = RST already wired up. Can they be declared here that way or must I declare and wire up as you have?
3) In main procedure, immediately before calling this sub-procedure, in order to [play], varI, varJ, varK, and varL are given a value. Immediately before calling this sub-procedure to [stop play], varK and varL are given a value. Some messages are only to be played once so [ 1 ] is assigned to both varK and varL when assigning [ play ]. Therefore, can I remove the else in the varK if statement and make varK and varL two separate if statements?
4) After file has stopped and sub-procedure has returned to main procedure, is it okay to code low B.3, low B.4, and low B.5 in main procedure?
5) You have w0 = varI which only has one digit. You also have a comment next to Gosub SetTrack saying w0 = 0000 to 0511. Will one digit work or do I have to make w0 equal to 4 digits using the if statements I had?
 

hippy

Technical Support
Staff member
1) That should be okay but it can depend on where cells are placed in a flowchart and the order in which they get processed when converted to downloadable code so it's best to put them in the cell which sues them.

2) You can keep it wired as you have it, just change the SYMBOL definitions to match.

3) If you remove the ELSE will the 'StopTrack' get called immediately after 'PlayTrack' ? If so nothing will get played.

4) You shouldn't be setting B.3, B.4 or B.5 low outside the routine unless there's a good reason for doing that. It will affect the module if you do. Also the procedure will return before the file has finished playing.

5) Values are the same with or without leading zeroes.
 

LouMar

Member
1) symbols in this sub-procedure per code below
2) wiring kept and symbols match: B.3 = DAT; B.4 = CLK; and B.5 = RST per code below
3) If varL=1 then 'StopTrack' called immediately after 'PlayTrack' otherwise 'Goto Back' follows 'PlayTrack' per code below
--- Will that work? ---
[varL 'if statement' inside varK 'if statement' will work when I send varK and varL both equal '1' and when varK=1 and varK=0 but when I send varK=0 and varK=1, 'StopTrack' can't get executed]
4) I will not make B.3, B.4, or B.5 low outside this routine (I won't make them low inside this sub-routine either - I will just leave them alone)
5) okay

Code:
Symbol RST = B.5
Symbol CLK = B.4
Symbol DAT = B.3

BasicCell:
  High RST
  High CLK
  High DAT

If varK = 1 Then
  w0 = varJ
  Gosub SetVolume ; w0 = 0 to 7
  w0 = varI
  Gosub SetTrack  ; w0 = 0000 to 0511
  Gosub PlayTrack
End If

If varL = 1 Then
  Gosub StopTrack
End If

Goto Back

SetVolume:
  w0 = w0 | $FFF0
  Goto TransmitW0

SetTrack:
  w0 = w0 & $01FF
  Goto TransmitW0

PlayTrack:
PauseTrack:
UnPauseTrack:
  w0 = $FFFE
  Goto TransmitW0

StopTrack:
  w0 = $FFFF
  Goto TransmitW0

TransmitW0:
  Low RST
  Pause 5
  High RST
  Pause 300
  For b2 = 0 To 15
    If w0 >= $8000 Then
      High DAT
    Else
      Low  DAT
    End If
    Pause 2
    Low CLK
    PauseUs 20
    High CLK
    w0 = w0 * 2
  Next
  High DAT
  Return

Back:
 
Last edited:

hippy

Technical Support
Staff member
3) If varL=1 then 'StopTrack' called immediately after 'PlayTrack' otherwise 'Goto Back' follows 'PlayTrack' per code below
--- Will that work? ---
It will do what it is told to do; it will begin playing the track then immediately stop playing so there won't be any audio output for that file.

You need to monitor the BUSY signal from the module which will be high when the file is being played and will go low when it completes.
 

LouMar

Member
3) Okay, I put the varL 'if statement' back inside the varK 'if statement' with the 'else' and that will allow the file to play when '1' assigned to varK and varL at same time or varK=1 and varL=0.
Now, how do I stop play when main procedure sends varK=0 and varL=1? Will this work: have another varL 'if statement' outside the varK 'if statement" as my post above. If that won't work, how do I stop play when the main procedure sends varK=0 and varL=1?

4) When I ran a simulation, after file stops play and sub-procedure returns to main procedure, pins for DAT, CLK, and RST are high. Since the file has finished playing, is it okay to make them low. When the sub-procedure is called again later in the program, they are made high again at BasicCell.
 
Top