Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:42 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Electronics : beginning picaxe for old dogs

     Page 2 of 5    
Author Message
VK4AYQ
Guru

Joined: 02/12/2009
Location: Australia
Posts: 2539
Posted: 10:22am 01 Jan 2010
Copy link to clipboard 
Print this post

Me Again

I see when Itry to leave a bigger space the forum format closes it up anyway....Bat1....Bat one refers to the battery see if that works

Bob
Foolin Around
 
oztules

Guru

Joined: 26/07/2007
Location: Australia
Posts: 1686
Posted: 10:23am 01 Jan 2010
Copy link to clipboard 
Print this post

Gizmo,
You may want to keep that win95 copy.

It is my understanding that 95 is Microsofts latest stable platform.... or was that Dos 6.....

I liked 95, 50m loaded, and worked. I notice that Microsoft then released a retrograde version called Vista.

They should have stayed with 95 and just added drivers perhaps.... couldn't be worse...... on todays machines it would be blindingly fast, but they claim that about Windows7 on their adds .... they know how to set a low bar.



..............oztules
Village idiot...or... just another hack out of his depth
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 10:27am 01 Jan 2010
Copy link to clipboard 
Print this post

Hi Janne,

Thanks for the correction.
It would be nice to have your involvement to help here.
I am not an expert on the picaxe and would like to give others the oppertunity to have some fun with these as many of us have had.
Please feel free to add a section to the Basic commands on any topic if you would like.
Every bit will help.
The more 4M involvement the better.

Pete.
Sometimes it just works
 
oztules

Guru

Joined: 26/07/2007
Location: Australia
Posts: 1686
Posted: 10:30am 01 Jan 2010
Copy link to clipboard 
Print this post

Bob...... re-read this from Downwind:
[quote]
There can not be spaces in a word used as a symbol like , time out , so for this we use an underscore to join the 2 words like , time_out .
[/quote]

So get into the habit....No gaps.... but could be Batt_1



............oztules
Village idiot...or... just another hack out of his depth
 
Dinges
Senior Member

Joined: 04/01/2008
Location: Albania
Posts: 510
Posted: 10:47am 01 Jan 2010
Copy link to clipboard 
Print this post

For those that grew up in the days of DOS (or worse... who set their first steps into PC land using CP/M ), using an underscore in filenames still comes naturally.

Old habits die hard....

Peter. (<-- reading the PICaxe stuff with interst in the background)
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 10:49am 01 Jan 2010
Copy link to clipboard 
Print this post

Hi Bob,

Your glasses are on the way and in the mean time ...I...w_i _l_l ....t_r_y ... t_o....t_a_l_k...s_l_o_w_e_r...f_o_r...y_o_u.

I do understand it is hard to get a mind around and even harder to try to put all this in a simple manner to explain it.

Once you have a play and ask a few questions and understand the answer it will be easy.

It is much easier writing your own little program as you know what the program should be doing to start with.

It is just a matter of finding a way to write it into program.
Trust me its not that hard. If i can do it anyone can.

Pete.
Sometimes it just works
 
VK4AYQ
Guru

Joined: 02/12/2009
Location: Australia
Posts: 2539
Posted: 10:51am 01 Jan 2010
Copy link to clipboard 
Print this post

Hi ozztubes

I meant in the explanitary text not the programing language

Bob
Foolin Around
 
VK4AYQ
Guru

Joined: 02/12/2009
Location: Australia
Posts: 2539
Posted: 10:59am 01 Jan 2010
Copy link to clipboard 
Print this post

Hi Pete

thanks for that, after I read it a dozen times it will sink in .....hopefully.....bat1....is the battery and I progress from there

All the best

Bob
Foolin Around
 
vasi

Guru

Joined: 23/03/2007
Location: Romania
Posts: 1697
Posted: 11:00am 01 Jan 2010
Copy link to clipboard 
Print this post

Yes, is a Firefox problem (tried with IE) so, to anyone wanting to follow the tutorial, use something else.

Vasi
Hobbit name: Togo Toadfoot of Frogmorton
Elvish name: Mablung Miriel
Beyound Arduino Lang
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5078
Posted: 11:57am 01 Jan 2010
Copy link to clipboard 
Print this post


The forum has a markup tag we can use to help format text. The tag is {CODE}, but replace the { brackets with a [ bracket, and the } bracket with a ] bracket.

So to display a bit of code, where we want to keep the formatting including spaces, I would use
{CODE}
for x=1 to 10
echo x
next
{/CODE}

Now if I use the correct brackets, we get.

for x=1 to 10
echo x
next


This tag was a bit buggy, but I think I've fixed it, let me know how it goes.

Glenn
The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5078
Posted: 12:11pm 01 Jan 2010
Copy link to clipboard 
Print this post

Its been mentioned before the forum tries to block users entering their own markup tags. It also throws random hidden characters into long words, like web site addresses. The forum does this as a security measure. The reason is simple, its blocking anyone adding script to the web page.

Below is a sample of harmless script

<script language=javascript>
alert ('Hello')
</script>

Now you can see this code because the forum converted the special characters, like < & >, into harmless html codes that are displayed, and not treated as pure html code. If the forum didn't do that, you would have recieved a popup message "Hello"

Same with long words, like web page addresses. The forum inserts spaces and other hidden characters to make the word safe, just in case it was a string of html characters built into a dangerous script.

Glenn
The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
Tinker

Guru

Joined: 07/11/2007
Location: Australia
Posts: 1904
Posted: 01:59pm 01 Jan 2010
Copy link to clipboard 
Print this post

Downwind,
My old laptop runs Windows XP and I bought the USB to serial converter for it to upload track data from a GPS. It worked fine but have not used it for some years now. The correct driver to do the above is already installed.

Re the odd embedded symbols, I'm running Firefox and it may have to do with that. I eventually guessed they represent some kind of quotation marks. Vasi's text shows exactly what I'm seeing.

  Downwind said   Tinker,

I have not used a usb to serial cable, but see there is a driver download for XP and Vista on the microchip site down the bottom of the page programming editor is downloaded from.
You might need this driver. I dont know.

It looks like programming editor is supported for Mac and Linux uses.
Have a look down the page at microchip as there is several downloads referring to these.

Pete.

Klaus
 
vasi

Guru

Joined: 23/03/2007
Location: Romania
Posts: 1697
Posted: 05:42pm 01 Jan 2010
Copy link to clipboard 
Print this post

Weird, no problems anymore in Firefox under Linux and Vista!... I think Glenn did something

Vasi
Hobbit name: Togo Toadfoot of Frogmorton
Elvish name: Mablung Miriel
Beyound Arduino Lang
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 06:06pm 01 Jan 2010
Copy link to clipboard 
Print this post

Hi Vasi,

He can be a trickie devil like that sometimes.

It might have helped that i edited all the inverted commas out of the text to.

Anyways good to hear the problem is fixed and a lesson learnt with using Winword to compile in. No " " allowed.

Pete.
Edited by Downwind 2010-01-03
Sometimes it just works
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 12:07am 02 Jan 2010
Copy link to clipboard 
Print this post

Waffle part 2.

Please ignore any …either side…of text as it is just to introduce some space in the text as requested and has no code meanings.


How a program works.

The chip reads the program as you would a book.
It starts at the top and reads line by line down the page.
Each line takes about 2 milliseconds to execute.
The program can be redirected to any point within the program, or at any stage up or down.
Like reading the book you might be told to see page X, figure 3.

The program needs a index point or reference point to go to as you did with …page X figure 3 in the book.

The index points used in a program are called …Labels …and the label must be followed with a colon ( : )

The two main commands used to direct the program to a Label is… GOTO …and… GOSUB.
Goto or gosub will direct the program directly to the nominated Label and jump everything in between.

The difference between the 2 commands… Goto and Gosub… is … GOTO… will jump to the label given and carry on with the rest of the program from there.

A …GOSUB …will return form the label to the next line below where it was sent from.

For this reason at the end of the labels operation there must be a statement…RETURN … added for any… Gosub used.

We will look at this in an example a little later, but first a few more explanations.

It is common we need to test a condition of a pin or a value stored in a variable … ( b0, b1,b2……b13 ).

For this we use a …. IF….THEN …statement.

Example.

IF pin3 = 1 THEN

High led

Endif
[/code]
Every… IF … THEN … must finish with a …ENDIF

This is because if the condition is true the program will preform every line in between the… IF …and the… ENDIF …. In this case turn the led on.

If the condition is false ( pin3 is low ) then the program will jump to the next line below the …ENDIF… and ignore everything in between.

Using Pin Numbers. ( no not your bank card number)

Each pin is dedicated a number by picaxe and can not be changed.

To use a pin as an… Output …we simply just use the number after the command.
Multiple pin numbers can be used in a single line but must have a comma between each number except the first digit.

Example

High 4,1,0,2

Using pins as …Inputs… we need to write this as …PIN3… or… PIN2….etc.

Example

If PIN2 = 0 '(low)

Same as above is

If pin2 = 0 ( low )… ( or ..if pin2 = 1 (high) )
Just another way of writing it.



Now with some of this strung together in a program

example.


Main:
If pin3 = 1 then '( 1 = high)
High 1
Low 4
Gosub Beep
Endif

If pin3 = 0 then '(0 = low )
Low 1
High 4
Endif

Goto main

Beep:

High 2
Pause 50
Low 2
Pause 50
High 2
Pause 50
Low 2
Pause 50
High 2
Pause 50
Low 2
Low 1

Return

Goto main
[/code]

Whats this all means?

Lets say we have a beeper connected to …pin 2…and a switch connected to … input 3… and every time the switch was pressed we wanted to turn the led connected to… pin 1… On… and hear …3 beeps… and then turn …pin 1 …led off.

If the switch is not pressed then the led connected to …pin 4 …will be On

The… Labels… in the example are …Main…and…Beep…

If the …Goto Main …was not the line above the label…Beep… the program would carry on through all the way to the bottom and it would beep 3 times every time regardless if the switch was pressed or not.

The …Goto Main… on the very last line is not entirely necessary as the …Return… should send it back to …Endif …below the …Gosub… But it is a good practice to include it in the event the program falls through to that point it is redirected back to the start and not off into lala land and would remain there till the power was switched off and back on again. Also known as a …HARD RESET.


Enough for now.

Pete.


Edited by Pete to be correct as Oz had pointed out an error.
Edited by Downwind 2010-01-03
Sometimes it just works
 
oztules

Guru

Joined: 26/07/2007
Location: Australia
Posts: 1686
Posted: 02:28am 02 Jan 2010
Copy link to clipboard 
Print this post

Yikes, With the linux version.. axepad.. I downloaded and it seems to work.

But, with the above program, it seems to stop at the first line and say syntax error. The only way around this is to use the fact that pin3 is a digital input and instead of:

If pin3 = high then I have to use: If pin3 = 1 then

and the same for the:

If pin3 = low then I have to use If pin3 = 0 then

The syntax check then checks out positive.

If I wrote it as 1 instead of high I should get the same result.... but how come you can use high instead of me using high??

Is it something I am missing, or is the linux one behaving differently to the windows one??


Puzzled pest oztules

Village idiot...or... just another hack out of his depth
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 05:01am 02 Jan 2010
Copy link to clipboard 
Print this post

Hi Oz,

You clever old dog
You have just won the booby prise of a half eaten chewy bone.
Well picked up on my mistake. Yes Pin3 should only read IF pin 3 = 1 than........( or 0 )
I was tired when writing it and brain not in gear.
Or should i say a intended error to see if you were paying attentison.
One thing about the 4m it will be a big syntax checker.
Good to see you have made the first step.

Go to the Help section of axepad and have a look at some of the information and print off the diagram for the pin outs of the 08M for a quick reference guide.

Pete.
Ps. Take the "s" out of pest.
Sometimes it just works
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 07:07am 02 Jan 2010
Copy link to clipboard 
Print this post

Here is the program for Gizmo's pump controller as used in the screen shots.
If you download the file and open it with axepad or prog. editor, depending what version you have.
It should read a little clearer and allow you to scrole through it for a closer look.
It is not a good program to run in the simiulator as it will get stuck in the .... pump_on_to_long....routine.

I will post both Glenns version and my rewrite of his program, they are the same just written 2 different ways so you can have a look at different approaches to the same outcome.

2010-01-02_165800_Gizmo's_pump_control.zip


2010-01-02_170609_Glenn's_pump_code.zip

Pete.
Sometimes it just works
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 07:23am 02 Jan 2010
Copy link to clipboard 
Print this post

Here is some simple LED programs i wrote with some kids some time back, that will show a few basic functions and you can load each into the chip for a look when you get a board.

2010-01-02_172301_SIMPLE_LED_PROGRAMS.zip

Pete.
Sometimes it just works
 
VK4AYQ
Guru

Joined: 02/12/2009
Location: Australia
Posts: 2539
Posted: 09:16am 04 Jan 2010
Copy link to clipboard 
Print this post

Hi Pete

Got crook on the weekend a
and up in the HOZZ PIDDLE have to catch up.

All the best

Bob
Foolin Around
 
     Page 2 of 5    
Print this page
© JAQ Software 2024