strange behaviour

craig008

New Member
i have writen a programme which runs fine when simulated, even over a period over a couple hours. but when loaded onto my 28x1 it bugs and does some strange stuff, it loads random numbers into the variables and displays randomly on the display. i dont understand what is going on

Code:
symbol control = b0
symbol temp_byte = b1
symbol temp_m = b2
symbol temp_h = b3
symbol sec = b4
symbol mins = b5
symbol hour = b6
symbol day = b7
symbol date = b8
symbol month = b9
symbol year = b10
'b11-b13 used for some switch counts
symbol Amin = b14
symbol Ahour = b15
symbol snoozetime = b16


init:
	hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte
	hi2cin 0,(sec,mins,hour,day,date,month,year,control)
	sertxd (#sec,#mins,#hour,#day,#date,#month,#year,#control,13,10)	'send data to computer
	if control = %00010000 then main						'check RTC to see if has data
'if the RTC has no data then write new values
	let sec = $00 
	let mins = $00
	let hour = $00 
	let day = $00
	let date = $00
	let month = $00
	let year = $00
	let control = %00010000	'set LED to flash
	sertxd (#sec,#mins,#hour,#day,#date,#month,#year,#control,13,10)	'send data to computer
	hi2cout 0,(sec,mins,hour,day,date,month,year,control)			'wrtie RTC
	pause 20
	
'********************
'***Main Programme***
'********************

main:
	let pins = %00000001								'Switch on display
	hi2cin [%11010000],0,(sec,mins,hour,day,date,month,year)		'read RTC
	pause 20
	gosub bcd_decimal									'convert data to readible info
	if temp_m <> mins then set_min						'check mins display
	if temp_h <> hour then set_h							'check hour display
	sertxd ("Time: ",#hour,44,#mins,44,#sec,13,10)				'send time to computer	if pin1 =1 and pin6 = 1 then set_alarm
	'if pin6 = 1 and pin1 = 1 then set_alarm
	'if pin1 = 1 then goto count_t
	'if pin6 = 1 then check_alarm							'check for time set
	goto main
	

'**************
'***Set Mins***
'**************

set_min:
	let b11 = 0
	let pins = %00000000								'Switch off display
	let temp_m = mins
	pulsout 3,10									'reset mins display
	
		set_cm:
			if b11 = mins then main						'check varible to ensure no over flow on display
			let b11 = b11 + 1
			pulsout 1,10							'increse mins display by 1
			if b11 < mins then set_cm
	goto main
	
'***************
'***Set hours***
'***************

set_h:
	let b12 = 0
	let pins = %00000000								'Switch off display
	let temp_h = hour
	pulsout 4,10									'reset hour display
	
		set_ch:
			if b12 = hour then main						'check varible to ensure no over flow on display
			let b12 = b12 + 1
			pulsout 2,10							'increse hour display by 1
			if b12 < hour then set_ch
	goto main
	
	


'***************************
'***Chanck BCD to Decimal***
'***************************

bcd_decimal:
	let temp_byte = sec & %11110000 / 16 * 10
	let sec = sec & %00001111 + temp_byte
	let temp_byte = mins & %11110000 / 16 * 10
	let mins = mins & %00001111 + temp_byte
	let temp_byte = hour & %11110000 / 16 * 10
	let hour = hour & %00001111 + temp_byte

	let temp_byte = day & %11110000 / 16 * 10
	let day = day & %00001111 + temp_byte
	let temp_byte = date & %11110000 / 16 * 10
	let date = date & %00001111 + temp_byte
	let temp_byte = month & %11110000 / 16 * 10
	let month = month & %00001111 + temp_byte
	let temp_byte = year & %11110000 / 16 * 10
	let year = year & %00001111 + temp_byte
	return
________
Bmw x-coupe
 
Last edited:

craig008

New Member
No takers, i dont understand why. i will go throught my circuit agian and see if anything else is cause the issue
________
Yamaha Gx1
 
Last edited:

Dippy

Moderator
"No takers, i dont understand why."
- ?? Maybe people are a bit busy with their own stuff??

Don't be disappointed Grapes.
Maybe the right person with an hour or two to spare has had the day off. After all you only posted your query just over 14 hours ago... and you can't expect everyone to be sitting by their PCs waiting for you to post a question - especially when there may be complications.

Maybe someone is working on it right now... free of charge ... just for you.

Please, please remember the answers/suggestions come from people who have a little spare time to help others. And reading other people's code takes longer than looking at your own code. Everyone has a different style.

You haven't said whether you're using a project board or a home-made pcb or breadboard or what. That can help. Help others to help you.
 

craig008

New Member
well considering you are the only other person that has looked at the thread i realy dont think that there is any body reading through the code, as for the last thread that the programme relates too nobody has looked at that either since i last posted on the 16th, but yet other people have posted and replied to posts, is it because i am not worthy to have my threads/questions looked at. please hippy tell me why arent people looking at my threads, while you are there why dont you tell me why need to rant insterad of being polite.

any way that aside
http://www.picaxeforum.co.uk/showthread.php?t=9583&page=5
________
HERBAL STORE
 
Last edited:

Technical

Technical Support
Staff member
Working on UK time, posting at 20.16 in the evening and then complaining you have no answer by 10.15am the next morning is a bit much!

See page 4 of the DS1307 datsheet. You will see that 00 is not a legal value for day, date or month. So it is not surprising that the DS1307 then behaves unexpectedly when loaded with this data.

Without knowing what the rest of the program does, e.g. the pulsouts, it is hard to comment further, which is probably why no-one else has responded either. If you provide more details within your posts to start with people may be able to provide more help.
 

Mycroft2152

Senior Member
Dear (sour) Grapes,

Let me add to Dippy's comments.

The forum is a bunch of unpaid volunteers/enthusiats spread all over the globe. For someone to spend the time to analyze and reply to a code snippet, usually means that it "catches their eye" and creates some interest in having done or doing somethng similar.

Look at the posts that have the largest number of responses, they have a very common interest to all.

A PICAXE date/clock circuit may be of prime interest to you, but in fact it is a rather mundane project to many. It can be a great learning project, but digital clocks are just too inexpensive to re-invent.

I had looked at your code and my reaction was,"yet another clock project :( "

There really wan't enough details "doesn't work, random numbers" to do anything with.

Myc
 
Last edited:

moxhamj

New Member
For quick questions you will get quick answers. This is a bit more complicated.

A complicated program will never work first time. Start with very simple subroutines and prove that they work on the real chip. Put each subroutine in one at a time. Use the 'debug' command and step through a program, sometimes one line at a time. Getting a program like yours working might take 50 downloads with debugs and leds flashing to check things are working. Then you can narrow down the problem(s). And you will always have bugs, even very experienced programmers have bugs in their programs.

For an answer to a complicated program like this we would need the full code, plus the schematic, plus a digital photo of the actual circuit. Technical has already spotted one error. But there might be others. What value decoupling capacitors are you using, for instance?

You will get some more replies. Please be patient. One minor little thing - there was no 'please' in the first post. It is but a tiny little word and it helps so much.
 
Last edited:

westaust55

Moderator
Grapes,

at this instant 79 people have "had a look" (otherwise know as viewed) at you posting.

I had a look between you "grumble" and Dippys repsonse.
I had gone so far as to copy your program listing into word to better have a look.

But then went to have my dinner (7pm here) but will be looking at my own project for a while now . . . .

As technical has given you a possible solution, maybe I will now look further at my own bit of soldering first.


Try applying Technical's comment in the meantime and let people know how you go.
 

moxhamj

New Member
Dippy, you were being extremely polite. You even said 'please' twice in a row. Can't get much politer than that.

I say, just for fun, wouldn't it be great to post what we are *really* thinking?
 

papaof2

Senior Member
"I say, just for fun, wouldn't it be great to post what we are *really* thinking?"

Waterproof keyboards are available, but I haven't yet seen one advertised as fire resistant ;-)

John
 

hippy

Technical Support
Staff member
I did read the post ( there are precious few I don't ) but I didn't respond. Dr Acula sums it up well; it was too complicated for me to even think about at the time as I was busy solving other problems and what I could have posted then wouldn't have been of any help.

If it's a simple question like "Can I run my PICAXE off 9V ?" I'll take the time out to say "No, except when through a regulator" as I can afford a few seconds and come back to it later, and by then others may have given far fuller answers and dealt with follow-up questions. Better a short-curt answer than nothing in that case, to save someone from doing smething they come to regret.

For complicated code it takes time to understand and investigate the problem and give a useful answer. Even as I'm typing this I'm up against a deadline I have to meet in a few minutes, so that's all for now.
 

hippy

Technical Support
Staff member
Back again, and I re-read the initial post to try and determine why I didn't respond. Having looked again I was left with a "Phew, you don't understand it ... nor do I". I'd put money on others having thought the same, and because it was out of their depth, beyond their experience or would take longer than they were prepared to give to investigate further moved along to the next post.

One problem is that "it bugs and does some strange stuff, it loads random numbers into the variables and displays randomly on the display" doesn't really help anyone take a quick scan at the code and guess what the problem may be intuitively. As it works in the simulator and no one's likely to have the same hardware configuration then intuitive guessing is all there is, or detailed in-depth investigation.

It's not the focused "I do X and Y happens when Z should" which makes people ask, "I wonder why", and start to postulate theories. It's more "this doesn't work", with the more automatic and base response, "oh well, you've done something wrong then", which people tend not to reply with even though they may think that.

Is it just a display problem ? Are the numbers really random or do they have some pattern to them ? How much have you done to isolate where the problem may be ? What do you know does work ? What happened when you replaced the HI2CREAD with a faked load of variables as would be read; does the display work then ? Maybe there are multiple problems ?

The code doesn't compile for me, the 'bcd_decimal' routine isn't provided; could it be a simple mistake in that ?

What do temp_m and temp_s do ? What's all that code about at set_min and set_s ?

What happens when you strip all the 'fluff' out and simply deal with reading the DS1307 and display the readings ?

As it currently is, there's just too many potential problems to say what the problem could be or where it may lie.
 

Ralpht

New Member
Ditto to all the above.

I am a hardware engineer so if the question was a hardware one I could answer quickly, complicated code will take a little thought, which sometimes I'm not predisposed to doing.

Commenting code really helps as well, no-one likes wading through obscure code trying to read the mind of the guy who wrote the original mess. I am a stickler for documenting everything, especially code. A week after I wrote something, I usually can't read my own stuff unless I put a ton of comments in to help things along.

Some manners and patience does help speed things up though.
And of course, our crystal balls regularly require servicing and mine is in the repair shop at the moment.

Dr_Acula - " I say, just for fun, wouldn't it be great to post what we are *really* thinking? "

In another life I used to start my emails (usually to salespeople) with ... Dear Richard Cranium .... (Dick Head) and it would go down hill from there.

Yes Doc, it really felt good.... especialy watching the response from the cry babies that were on the recieving end of them.

I wonder why I'm no longer employed there ......;)
 

slimplynth

Senior Member
Is that Ostrich boiling his head in the sand?

Come on Grapes, at least apologise - no point burying your head in the sand. I'm a newbie and have read bazillions of posts (well a few at least:)) from the seniors/mods on this thread. Their help, knowledge and patience is second to none and best of all they give it away for free!!!

God damn it. I don't think a showing some respect is going OTT, even if you have been pulling your hair out over something that doesn't work.

A little respect, humility and humour goes a long way.
 

Dippy

Moderator
Well I do my best to be diplomatic, though my sarcastic/jovial streak gets the better of me sometimes. And it's easy to slag people off from a distance, so I don't (usually).

Like I've said before; this Forum is not Ask Jeeves and, as said numerous times above, is a voluntary help service by people who like to help and give their time. (Emphasis on GIVE!!)

Try and get the same level of help from Microsoft (or most places) free of charge. Haha... sorry I nearly went into an hysterical fit there.

Also, Grapes said he/she was going to check his/her circuit, suggesting it is a homebrew. So in addition to any coding issues there maybe hardware issues - and no schematic or anything has been supplied. And then he/she gets a bit (diplomatically) impatient when no-one can supply the magic answer within a day or so.

If it were a bug/warranty enquiry I, too, would expect a quick-ish reply, but this looks like a user error and without all the info a solution is tricky.. and time consuming for the 'old lag' who wants to get involved. I'm certain that if the solution was fairly obvious then someone would have chipped in by now.
But after the somewhat abrupt posting then people may have lost their enthusiasm to help.
It's a pity really but there we are.

Note: When I posted my first reply this thread had 62 views. This indicates quite a few people had a look, scratched their heads and went away.

Note2: Grapes, break your code up and try it in manageable parts, then it gives you a chance to zero in. Example: you said it writes rubbish to the LCD. Well, have you just tried a minimal bit of code just to write known values to the LCD? (Just to see if the problem is there?). Do it in parts. Do it all in parts.
 
Top