Picaxe 28x1 hsersetup?

No0bert

Member
After consulting the Picaxe manual, I have concluded with the following code:

hsersetup B115200_X, %10 'setup serial to save to scratchpad
pause 10000 'power on the cmucam in this 10 seconds
b1 = hserptr 'the hserptr holds the number of bytes rcvd (CMUCam1.12), store that in b1
hserptr = 0 'reset the pointer to the start of the rcvd data
for b2 = 1 to b1 'iterate through the data
sertxd (@hserptr) ' re-transmit the item
hserptr=hserptr+1 ' increment the pointer
next b1

I apparently, need to set the X as described in the manual under hsersetup, however, I cannot find this, which is where some lucky Picaxe Pro comes along.

I think it has something to do with my chip's clock rate?
So I conclude with the question, what do I subsitute in for "X" in that code? And whether or not this code will run successfully with the CMUCam v1.2?
 
Last edited:

inglewoodpete

Senior Member
Please refer to the command manual: hSerSetup. The X is explained there (refers to the PICAXE clock speed). I'm not sure what the problem is, unless you have a very old version of the manual.
 

No0bert

Member
Please refer to the command manual: hSerSetup. The X is explained there (refers to the PICAXE clock speed). I'm not sure what the problem is, unless you have a very old version of the manual.
I still dont get it, I subsituted 40 in for X, as well as 16, am I wrong on both of these, even so I get a syntax error when trying to compile both of these
 

westaust55

Moderator
Not sure what is hard to understand about the table in manual 2 on page 64.

X should be substituted with the speed at which the PICAXE is operating.
Most likely a value of 4 unless you are using the SETFREQ command

EDIT:
Might also ask, what has been the outcome for your robot code thread ?? Have you resolved that or leapt into a new "adventure".
 
Last edited:

No0bert

Member
Not sure what is hard to nderstand about the table in manual 2 on page 64.

X should be substituted with the speed at which the PICAXE is operating.
Most likely a value of 4 unless you are using the SETFREQ command

EDIT:
Might also ask, what has been the outcome for your robot code thread ?? Have you resolved that or leapt into a new "adventure".
I have not yet resolved it, and nor have I "leapt into a new adventure" because I was planning on using the CMUCam with that robot with the code, I was planning on asking my friend who is a pr0zors programmer
 

hippy

Ex-Staff (retired)
Please refer to the command manual: hSerSetup. The X is explained there (refers to the PICAXE clock speed). I'm not sure what the problem is, unless you have a very old version of the manual.
I still dont get it, I subsituted 40 in for X, as well as 16, am I wrong on both of these, even so I get a syntax error when trying to compile both of these
The following compiles as expected without error using Programming Editor 5.2.1 ...

HSerSetup B115200_16,%10

I'm not sure what problem you are having either; can you please post the line of code and details of exactly what error is being reported. Plus make sure you have 28X1 selected in Viiew->Options->Mode.

B115200_40 will give an "Unknown symbol " error because 40MHz operation is not supported on the X1 devices.
 

BCJKiwi

Senior Member
Hippy, your note re 28X1 selection reminds me of the request/suggestion I have put up previously but on which there has been no feedback.

I really think it would be a very good idea for the the progam editor to REQUIRE the #PICAXE 28X1 directive to be specified in the program.
If multiple target chips could be specified that would be even better - warnings/errors could be generated for code that does not comply with the chip specified.

I note this is a requirement for the compiler.
 

No0bert

Member
OK, now when I try to compile, it goes past the HSerSetup command, and finds a syntax error:

HSerSetup B115200_16,%10 'setup serial to save to scratchpad
pause 10000 'power on the cmucam in this 10 seconds
b1 = hserptr 'the hserptr holds the number of bytes rcvd (hopefully CMUcam v1.12 etc), store that in b1
hserptr = 0 'reset the pointer to the start of the rcvd data
for b2 = 1 to b1 'iterate through the data
sertxd (@hserptr) ' re-transmit the item
hserptr=hserptr+1 ' increment the pointer
next b1

saying: Unknown Symbol - @hserptr

btw thanks hippy :D
 

Technical

Technical Support
Staff member
You can't use @ with hserptr.

Code:
HSerSetup B115200_16,%10 'setup serial to save to scratchpad
pause 10000 'power on the cmucam in this 10 seconds
b1 = hserptr - 1 'the hserptr holds the number of bytes rcvd (hopefully CMUcam v1.12 etc), store that in b1
hserptr = 0 'reset the pointer to the start of the rcvd data
ptr = 0
for b2 = 0 to b1 'iterate through the data
[B]sertxd (@ptrinc) [/B]' re-transmit the item
next b2
 
Last edited:

inglewoodpete

Senior Member
NoObert, Did you mean to use SerTxd or HSerOut? HSerOut is usually used with HSerSetup:

Code:
   Symbol SendNoBreak = 0
   HSerOut SendNoBreak, (@PtrInc)
Of course, these commands use the hardware pins (legs) dedicated to hardware serial - 17, 18 on the 28x1.
 

No0bert

Member
NoObert, Did you mean to use SerTxd or HSerOut? HSerOut is usually used with HSerSetup:

Code:
   Symbol SendNoBreak = 0
   HSerOut SendNoBreak, (@PtrInc)
Of course, these commands use the hardware pins (legs) dedicated to hardware serial - 17, 18 on the 28x1.
Honestly I have no clue, the entire code is straight from the manual, and I am trying to get this Cam to work with Picaxe, I have yet to find any blob recognition, or any codes for any cameras connected to the Picaxe28x1 chip
 

westaust55

Moderator
Honestly I have no clue, the entire code is straight from the manual, and I am trying to get this Cam to work with Picaxe, I have yet to find any blob recognition, or any codes for any cameras connected to the Picaxe28x1 chip
Can you please give a link to the manual from which you have taken the code you are using.



Are you using the iV-Cam_e as per the attached info?

If so,
1. that datasheet states: The most common configuration for the iV-CAM is to have it communicate to a master processor via a standard RS-232 serial port. Are you going through an RS232 type chip? (MAX232) or are you conencting to the separate Rx and Tx headers which can connect direct to a microcontroller?

2. serial communication at 115,200 / 38,400 / 19,200 / 9600 baud serial communication.
Why not start with a slower baud rate like 9600 and when that is working try the faster comms speeds.

If fact the example code for the Basic Stamp toward end of the attached datasheet (section 12.1) used 9600 Baud.

3. The BS2 example code is using the SERIN and SEOUT commands.
PICAXE has these same commands but you will need to operate at the 8MHz speed to get the 9600 baud comms rate.



Can I respectfully suggest that you start again, and state:
- Your own overall programming experience
- Your PICAXE experience
- Your own robot experience
- Your own electronics design and/or construction experience

- explain exactly what you are doing,
- what equipment you have,
- where your code came from

and give more details rather than “I have this piece of code direct from the manual” and it is not working.

It is like your Robot code thread which is a “direct copy from two other working robots“ yet my initial look found code a structure error.
 

Attachments

Last edited:

No0bert

Member
Can you please give a link to the manual from which you have taken the code you are using.
Its not all together, but 100% of it is from the manual...

Are you using the iV-Cam_e as per the attached info?

If so,
1. that datasheet sattes: The most common configuration for the iV-CAM is to have it communicate to a master processor via a standard RS-232 serial port. Are you going through an RS232 type chip? (MAX232)
I took the MAX232 chip out because it was not needed because I believe its for connecting the CMUCam to a PC, via the SX-Key ports

2. serial communication at 115,200 / 38,400 / 19,200 / 9600 baud serial communication.
Why not start with a slower baud rate like 9600 and when that is working try the faster comms speeds.
Well do.
 

westaust55

Moderator
Ooops,
I went back to add some more comments to my previous post but got side tracked . . . .
By the time I hit submit you have responded to my first part. :eek:

Maybe you can re-read my revised earlier post
 

inglewoodpete

Senior Member
No0bert, I think you may need to get back to basics with the PICAXE and build from there. Firstly, find out how the H/W Serial commands, scratchpad and data are handled.

The following url is for another discussion on using the Hardware Serial interface on the 28x1 and 40x1. While the other discussion is on a different aspect of HSerial, it includes some code I wrote to help me understand how to handle a H/W serial interface in background mode. To make this work with your PC, your will need to move the serial cable from the download pins to the dedicated hardware serial pins (via a MAX232).

The code was written to interface the PICAXE via a MAX232 with the PE's terminal programme. Characters typed from the PC are echoed back the the PE terminal.
Previous discussion on Hardware Serial Configuration

-Peter
 
Last edited:

No0bert

Member
Can I respectfully suggest that you start again, and state:
- Your own overall programming experience
- Your PICAXE experience
- Your own robot experience
- Your own electronics design and/or construction experience

- explain exactly what you are doing,
- what equipment you have,
- where your code came from

and give more details rather than “I have this piece of code direct from the manual” and it is not working.

-Very Very weak programming, I have only learned C++, and even that, very weak
-Moderately Strong
- Very Strong, but thats just mechanics/construction
- Moderately Strong

It is like your Robot code thread which is a “direct copy from two other working robots“ yet my initial look found code a structure error.
Turns out that crap was in "test" mode, so alls I had to do was delete some line that triggered the loop in the begining... so I felt really dumb
 

tiscando

Senior Member
Try this: ptr is just like a general variable, only that the number inside it controls the scrachpad pointer.
Code:
HSerSetup B115200_16,%10 'setup serial to save to scratchpad
pause 10000 'power on the cmucam in this 10 seconds
b1 = hserptr - 1 'the hserptr holds the number of bytes rcvd (hopefully CMUcam v1.12 etc), store that in b1
hserptr = 0 'reset the pointer to the start of the rcvd data
for ptr = 0 to b1 'iterate through the data
sertxd (@ptr) ' re-transmit the item
next ptr
...
 
Top