How difficult would this be?

chigley

Senior Member
Just a small update re. the timings. I've now confirmed that the timing errors are definitely being caused due to small delays when commands are being run on the PICAXE, which are adding up throughout the song, eventually leading to the bot being multiple notes behind.

I'm at my Dad's this weekend, where we'll be getting the oscilloscope out to try to work out the appropriate offsets to be added at which points to rectify this!
 

chigley

Senior Member
Hi all. Another update!

We got the oscilloscope out today and worked out that I needed to add 1ms to each pause delay in between notes. This then played the song perfectly (!) using code similar to that in post #65 of this thread.

Unfortunately I couldn't play an entire song due to the programme size limit on the PICAXE 18X. I then did some reading about binary, bits and EEPROM page buffers and came up with code like this to write to the EEPROM:

Code:
i2cslave %10100000, i2cfast, i2cword

writei2c 0, (%00000000, %00000000, %10000001, %00000000, %00110101)
pause 10

writei2c 8, (%00000000, %00010000, %00000101, %00000000, %00101000)
pause 10

writei2c 16, (%00000000, %00011110, %01000001, %00000000, %00110101)
pause 10

writei2c 24, (%00000000, %00010000, %00000101, %00000000, %00101000)
pause 10

writei2c 32, (%00000000, %00011101, %00001001, %00000000, %00110101)
pause 10

writei2c 40, (%00000000, %00010001, %00000101, %00000000, %00101000)
pause 10

writei2c 48, (%00000000, %00011101, %10000001, %00000000, %00110101)
pause 10

[...]
I then rewrote the bot code to read in the data in a loop, and alter the note outputs accordingly:

Code:
i2cslave %10100000, i2cfast, i2cword

main:
	if pin2 = 1 then playsong
	goto main

playsong:
	w3 = 0
	do until w3 > 4224
		readi2c w3, (b3, b2, b1, b5, b4)
		pause w1
		let pins = b1
		pause w2
		let pins = %00000001
		w3 = w3 + 8
	loop
	goto main
As suspected, the timing is now disrupted. The wave form shown by the oscilloscope was inconsistent, even if the data being read in from the EEPROM was exactly the same each time the programme looped. I'm hoping that with a bit of fiddling with the time delays, and some trial and error, I'll be able to get it working - this worked first time round!

I know that the asynchronous 'guessing' game isn't the best way to work, but I can't think of a solid way of calculating exactly which amendments are required. The only thing I thought of was upgrading to a 28X1, and using the settimer function, as this would be a much tidier and synchronous method. This isn't desirable though as I'd have to make another board from scratch, and I really don't need the additional 10 outputs! The only other option would be to use an alternative storage system to EEPROM.

I'm going to refrain from making any hardware changes at this point. With a bit of trial and error I'm hopeful that I can get this working.

Just thought I'd post my status for those who are interested! Almost there :)
 

hippy

Ex-Staff (retired)
By twiddling with Timer2 via SFR's you should be able to get a fairly accurate timebase. Unfortunately that means delving into the depths of PICmicro datasheets.
 

BeanieBots

Moderator
Now might be a good time to back to the begining of this thread and read it all through again. The answers (and warnings) to your latest observations are all there.
 

chigley

Senior Member
Now might be a good time to back to the begining of this thread and read it all through again. The answers (and warnings) to your latest observations are all there.
I just read over the entire thread. There's a couple more options which I could explore, but I'm still going to try my best to fudge it with the EEPROM!
 

vttom

Senior Member
I'm hoping that with a bit of fiddling with the time delays, and some trial and error, I'll be able to get it working - this worked first time round!
Here's a suggestion. If you need a variable amount of delay, put a 10k (or so) potentiometer between VDD and GND and put the middle terminal into one of the ADC input pins on the PICAXE. This is nothing more than a continuously-variable voltage divider.

In your main program loop, take an ADC reading of that pin and use the value to set the delay amount (you'll probably need to multiply it or divide it by some fixed amount to get the right magnitude).

To "dial-in" just the right delay while your program is running, you literally turn the knob on the pot.
 
Last edited:

chigley

Senior Member
Hello again!

Can't believe it's been a month and a half already since I last worked on this project. Since then I've been on 3 holidays, have moved house, and have started back at college. Unfortunately due to the house move there was a prolonged period where I had no internet connection. I still don't have the internet properly, but am just about getting by with a USB 3G dongle for the time being.

I've not given up on my GH3 robot project though! I've decided that with the current setup, and the asynchronous timing methods and guessing involved, it just isn't going to work. Whether it's the 8MHz clock speed of the 18X that's too slow, or irregular EEPROM read times, I simply couldn't maintain perfect timing for more than a minute.

I've therefore decided to upgrade to a PICAXE 28X1. This opens up the ability to run it at 16MHz, with a more accurate external resonator. It also allows me to use a VDRIVE2 as suggested on the first page of this thread to store the note charts, as opposed to the EEPROM. This means that it will be far easier to update/correct the note charts whilst debugging, and will make it more adaptable in the future. I'm also aware that using the 28X1 opens up the opportunity to use the settimer function. If I can get this to work, it'd be brilliant, but ideally I'd need a major tick to occur every 1ms, which I believe isn't possible. With a bit of maths, I may be able to alter all of the timestamps in the note chart on the VDRIVE2 such that the settimer function can be used to time in the notes if I can work out a good tick interval which is compatible. I'll have to wait and see!

You'll also see that I've added in support for the use of the whammy bar and star power buttons (transistor controlled in the same way as the green/blue notes) to allow for higher scores in the future after all other problems have been sorted. I've also left a pin free to interface with the AXE033 LCD display if the project ever advances enough into having a menu display whereby the user can select a song from a list for the robot to play. I'm not getting ahead of myself here; I'm just planning for the future so that I don't have to make a third board!

Here's the new stripboard layout I've come up with:



There's bound to be some mistakes somewhere. I've never worked with an X1 part before, nor a VDRIVE2, so I'm not too confident in their connections! I have checked over it myself, but I'd appreciate it if anyone could find the time to check over it too just in case there are errors.

Programming all of this should be fun! I've found some sample VDRIVE2 read/write code on the forums, and have read the appropriate manuals. As long as the hardware is correct, I should be able to get it working eventually!

Hopefully I'll get the 100% full combo on the song eventually! :p

Thanks for your time,

Charlie

EDIT: I just realised that I forgot the 10k pull-up resistors on the collectors of the transistors, used to ensure that the frets are in the "off" state when the transistor is not switched. The stripboard layout above has been updated.
 
Last edited:

chigley

Senior Member
Another quick update!

I've just finished drawing up the schematic of the newer version of this project (the 28X1 version.) Note that I've also included an updated version of the stripboard layout, as I'd forgotten to pull the unused input pin on the 4066 to 0v.



I don't have a clue if the symbol on the schematic for the 16MHz ceramic resonator is correct. A quick Google didn't reveal much either. Care to enlighten me, anyone? :)

As always, feedback greatly appreciated! I'm hoping to construct this as soon as possible, but I'm having problems balancing my time at the moment!

Charlie
 

Dippy

Moderator
Your symbol looks fine.
The resonating element + 2 load caps is a good representation.
The symbol drawing is how you'd wire up a crytsal (or a 2 legged res.), so its a good reminder.

I haven't checked the circuit/pinouts or stripboard though - my time balance is has to go to work ;)
 

chigley

Senior Member
Thanks for the replies :)

I think I have all of the components I need now. Just need some free time in which I can construct it!

Does anyone have any advice about the cleanest way to wire the VDRIVE 2 to my board? The ribbon cable has a connector on the end, presumably for use with pin headers. The holes in the VDRIVE connector are far closer together than the pin headers which could be soldered onto the stripboard, so they won't line up. The only solution I've thought of is to cut off the connector at the end of the ribbon cable, and then use terminal blocks. Can anyone think of anything better? (Hope all of that makes sense!)

Charlie

EDIT: Decided I can't be bothered even to use terminal blocks. I'd have to change my stripboard layout, to double space the connections for the VDRIVE and Xbox 360 interface connections. Just had a go at making these changes, and it's verging on impossible to do. Quite frankly I'd rather just hard-solder it to save me the time it'd take to massively change the board layout. Lazy, I know.
 
Last edited:

chigley

Senior Member
Small update.

I built the newer (28X1) circuit a couple of weeks back, all of the hardware side of things is working perfectly.

I've spent the last two weekends playing with the programming, trying to work out a good format for the data on the VDRIVE2, have managed to read in a few bytes, but am yet be successful! It doesn't feel stable/consistent at all.

Will update again if I get anywhere :)
 
Top