Problem/Help with code/ Connections?

No0bert

Member
Hello, I am new here at these forums, and I need some help with coding/connections. Ok, heres the scenario, my code is perfect, I know this because I have tried it on two other bots, working flawlessly, using the same MCU, the PIcaxe28x1 (AXE020) with the ULN2803A transistor array, and one L293D motor Driver chip in the 16 DIP socket. My connections are:

Two Base Motors- A-B connections
Playback- Portc 3
Record- Portc 2
Speaker- Output 0
Single Directioned motor, using another L293D chip (externally from the board) to drive the motor- connects to portc 4+5
Right Motor- Ouput 2
Left Motor- Output 1
Back Motor- Output 3

These three last motors use the Transistor array on the board to switch from highs and lows (on and off), making a 60° angle

The SRF05 is connected to Output 1(TTL (In between the Picaxe Chip and Darlington Array)) and Input 0

Everything works absoultely fine except its not doing what its supposed to (what the other two bots did) in according to the code.

What it actually does is, right when I plug in the power supply, it starts doing the first "beat" in the code, and continues doing that in an endless loop, everything works fine (the base motors, all of the transistor motors, and the externally drivin (by L293D) bi-directional motor, the Playback, record, and speaker, and the SRF05 LED blinks red (means it works)

What its supposed to do, I believe, is first roam around, using the base motors, and panning the externally driven motor with the SRF05 on top, search for an obstacle, and when it finds the obstacle, snake into place, and then start the sequence "beat", and from there it should continue until the minute or so is up, and then go onto a next object. You see, it doesnt do this, it just plays a single beat without searching.

Attatched is the code, can someone help please?
 

Attachments

eclectic

Moderator
Ok, heres the scenario, my code is perfect, I know this because I have tried it on two other bots, working flawlessly, using the same MCU, the PIcaxe28x1 (AXE020) with the ULN2803A transistor array, and one L293D motor Driver chip in the 16 DIP socket.

Everything works absoultely fine except its not doing what its supposed to (what the other two bots did) in according to the code.

What its supposed to do, I believe, is first roam around, using the base motors, and panning the externally driven motor with the SRF05 on top, search for an obstacle, and when it finds the obstacle, snake into place, and then start the sequence "beat", and from there it should continue until the minute or so is up, and then go onto a next object. You see, it doesnt do this, it just plays a single beat without searching.

Attatched is the code, can someone help please?

Well, if it worked perfectly, twice, then make an exact replica of the robot that worked. It should be easy the third time.

Time for supper. My normal tika chicken.

e
 

inglewoodpete

Senior Member
I had a look at the code. Nearly 1400 lines of code with hardly an explanatory comment. Thats quite an achievement!

No wonder professional programmers get paid over $100 per hour. They have to interpret other people's undocumented code. Sorry, I have to wash my hair tonight.
 

westaust55

Moderator
Firstly, as already stated, you DO NEED to learn to format you code well with indents and add more comments to enable others to understand well what is supposed to happen.


I had a quick look through the code flow and found what appears to be a problem . . . .
There is NO WAY I will sit down and go thru all of this code.
I suspect there is NO WAY it is a 100% copy of working code in you other robots from what I have spotted already.


In summary the code flow starts as follows:

Code:
Variablesetup:
  Makes portc pins 1 to 7 high and thus all as OUTPUTS
  Symbol declarations

YDMIIsetup:
  goto finishsetupYDMII:  ; <===[B]NOTE does not need a colon here after the label name[/B]

finishsetupYDMII:
  symbol declarations
  [B][COLOR="red"]goto[/COLOR][/B] playsomebeats  ; ?????  [B]NOTE[/B] that elsewhere you use [B][COLOR="red"]GOSUB[/COLOR][/B] Playsomebeats

playsomebeats:                             
  Gosub offplayback   
  pause 50
  Goto player

offplayback:
  high portc 3 ' off playback
  return 

player:
  has many gosubs to other routines like aaaa, bbbb, cccc, dddd etc
  gosub headforward
  [B][COLOR="Red"]return[/COLOR][/B]       ; here we have a [COLOR="red"][B]return[/B][/COLOR] but because the ealier command was [B][COLOR="red"]goto playsomebeats[/COLOR][/B] where will it return to ???????


headforward:
low portc 5 low portc 4  ' Head Forward
return

gave up here because already a potential problem spotted above

This is a large picece of code. I think that you need to draw up a flow diagram of you code and follow it through yourself. Check things like that spotted above.
Is the a RETURN for every GOSUB and a RETURN for Every GOSUB?
 
Last edited:

westaust55

Moderator
“I’ve been wrong twice in my life, and one of those times I was wrong” ;)
Then again, I've had a message that my post is too short twice now.
Last time the limit was minimum of 10 characters . . . .
Maybe a quote does not count :confused:
 
Top