PDA

View Full Version : 12f675_fuse_about_to_blow!



Pages : 1 2 [3] 4

mackrackit
- 31st May 2010, 23:59
Yup.
Only thing is they do not " shine" very far. Maybe 10 feet max. You will have to check the data sheet for angle and brightness.

Might get an idea of how it will work by using the remote to light something up. Use video mode and get the retro strobe effect :)

LEDave
- 1st June 2010, 17:21
Hi mackrackit,

The IR led on my TV / Video remote doesn't shine that bright, you'd need a fair few of them to match a flashgun I'm thinking, although I did get the flashing strobe effect.

I drew a complete blank with the camera kit last night. Tomorrow should be a much better night weather wise, so I might set the camera up in the garden for a clearer picture

mackrackit
- 1st June 2010, 21:19
The LED in the remote is not driven very hard, only has 3 volts or so behind it and is pulsing.

Take a look at this
http://www.lasertagparts.com/mtoptics.htm
The LEds used are "high power" and you could even use the lens setup for a spot light kind of thing. Take a key-chain LED and a magnifying glass and at the correct LED to lens distance... well you will be surprised. Good for demonstrations.

LEDave
- 1st June 2010, 22:28
That was an interesting read, I'll have a look around and try and source some parts for and IR led and lens combo.

I must say though I was very surprised the Badger hung around for 47 photo's and wasn't scared off by the flash continually firing.

I've had an idea to make my fortune by the way:

The fact that I captured a Badger at my very first attempt means I must be a natural at this:)
And I've heard that you guys in America have a thing called the Bigfoot or the sasqcatch that nobody has any pictures of right? I coud be that man! Then again the Badger has pretty big claws not to mention a Bear and as for Bigfoot.....perhaps I'd better reconsider:eek:

Camera's set up for night3.

Dave

mackrackit
- 1st June 2010, 22:44
Start off with solving the crop circles you have over there :)
Might be big foot on holiday :eek:

LEDave
- 2nd June 2010, 00:32
Lol............:D

LEDave
- 2nd June 2010, 09:57
Last nights picture:)

Please note the cunningly hidden PIR detector inside the old Cornflakes packet itself inside a polythene bag (bottom LHS).

Dave

mackrackit
- 2nd June 2010, 12:49
If you could place some of the IR LEDs as close as you have the PIR you should be able to light the feed dish up like daylight.

Another thought .... Good thing big foot does not eat peanuts :p

LEDave
- 2nd June 2010, 13:50
If you could place some of the IR LEDs as close as you have the PIR you should be able to light the feed dish up like daylight.

I'll see what I can order up. It will be interesting to see the results of an LED v's flashgun.


Another thought .... Good thing big foot does not eat peanuts

Too right, The Badger's costing me a fortune......:eek:

LEDave
- 4th June 2010, 14:38
Last nights pictures, the best so far I think:)

Dave

mackrackit
- 4th June 2010, 15:37
Those are great.
How did you do the lighting?

LEDave
- 4th June 2010, 16:07
Hi mackrackit,

The lighting was the camera flash (I'm still looking into IR_LED's) But I placed some diffuse material over the flash lens (Ok I'll fess up, it was a small piece cut from the plastic bag inside a cornflakes packet). It seemed to work though, still some flash flare but not bad.

Dave

mackrackit
- 4th June 2010, 16:17
I never thought of doing that. Makes sense.

Will have to remember that for later. ;)

LEDave
- 6th June 2010, 18:21
Set the camera up last night and had a nice phot_set of someone's cat:eek:

I'll post any good or interesting pictures up as they occur.

Right then, what's the next 'Mission' / 'Project' mackrackit? Or are you working on one?

Dave

mackrackit
- 6th June 2010, 20:25
To be honest I have been tied up with some other "stuff"...
I will think of another mission soon.

LEDave
- 6th June 2010, 20:37
I will think of another mission soon.

As and when mackrackit, absolutely no rush at all. I'll try and get some IR_LED's and a lens to make a night light for the camera when I can source some kit.

Dave

mackrackit
- 6th June 2010, 21:17
Being we are sorta on the subject of surveillance/security/IR...
What about an IR "trip wire"?
And while you are doing IR "stuff", maybe some IR comms also?
http://www.rentron.com/Infrared_Communication.htm

LEDave
- 6th June 2010, 21:26
What about an IR "trip wire"?
And while you are doing IR "stuff", maybe some IR comms also?

Sounds good to me:) Is there anything these PIC's can't do......?

Dave

mackrackit
- 6th June 2010, 21:32
Sounds good to me:) Is there anything these PIC's can't do......?

Yes... But we do not talk about that here :rolleyes:

LEDave
- 6th June 2010, 22:10
Lol......:D

mackrackit
- 9th June 2010, 09:27
How are you coming with the IRs?

A few years ago I did a laser "trip wire". The same thing can be adapted to IR.

The laser pulses at a given rate so the sensor can not be defeated by another laser or bright light. Think of those silly movies where the laser system is defeated with mirrors and such. Can not happen, or not likely to with this.

I used a simple laser diode like you would find in an office pointer. and a photo-transistor for the sensor. The sensor was placed in a 24 inch long tube so ambient light would not was it out. Night time monitoring would obviously not need this.

So here is the code if you want/need ideas. As always there are several ways to do this that may or may not be more efficient. But this system has been monitoring a quarter mile long line for around three years now.

Laser Pulse:

DEFINE OSC 4

LOOP:
HIGH GPIO.4
PAUSE 20
LOW GPIO.4
PAUSE 95
GOTO LOOP

Laser Sensor:

DEFINE OSC 4
LP VAR BYTE

START:
COUNT PORTC.1,100,LP
IF LP <> 1 THEN CHECK
HIGH PORTC.5 'HEART BEAT LED
PAUSE 50
LOW PORTC.5 'HEART BEAT LED
PAUSE 50
GOTO START

CHECK:
COUNT PORTC.1,100,LP
IF LP <> 1 THEN BREACH
GOTO START

BREACH:
'DO SOMETHING
GOTO START

LEDave
- 9th June 2010, 16:49
How are you coming with the IRs?

I've been wondering about this:

http://www.maplin.co.uk/Module.aspx?ModuleNo=265568

I know it's not an IR_LED_Lens combo but it does "Provides 5m visibility coverage with a camera"

Interesting project that with the laser. How difficult was it aligning the transmitter with the receiver over that distance?

Dave

mackrackit
- 9th June 2010, 19:05
That LED array looks like it would really light things up. Might just be what you are looking for. The lens idea was for some distance and intensity if you are only using one or two LEDs.

Laser alignment was a ... very difficult.

The laser and sensor are mounted on 2 inch heavy walled pipe cemented into a 3 x 3 x3 foot chunk of concrete. We did/do the alignment at night with a 4 x4 foot piece of plywood to start with. Every once and a while with the change of seasons and all the earth quakes we have here it has to be re-adjusted. At that distance the laser spot is couple of inches in diameter so there is a little forgiveness.. But I should build a bigger target.

LEDave
- 9th June 2010, 22:30
I guess over that distance the trans / rec would have to be mounted rock solid (literally).

You must have a seriously big back garden mackrackit to have to transmit over a quarter mile:D
I wouldn't like to have to cut you're garden grass:eek:

I'm going for the Maplin IR_Display. Do you think it will put enough light out to take a picture at a reasonable shutter speed without using the flash?

Dave

mackrackit
- 10th June 2010, 00:05
I wouldn't like to have to cut you're garden grass
It is all sand where I live :eek: with no ocean.


I'm going for the Maplin IR_Display. Do you think it will put enough light out to take a picture at a reasonable shutter speed without using the flash?
I would guess yes if you can place it close enough to the target like you had the PIR in the cereal box. It will be directional like a flash light (hand torch?).

LEDave
- 11th June 2010, 22:34
IR_LED module ordered up, should arrive early / mid next week. It will be interesting to see how well the camera works under this kind of light.

Dave

tiresmokindad
- 13th June 2010, 08:27
Hi everyone. Oh boy do I need some help here!

I've just purchased a PICkit1 Flash Starter Kit. I've loaded the MPLAB IDE software and the PICkit1 Classic program and been able to load and re-load the demo hex code.

So, time for me to program the 12F675 to turn a single LED on, oh deary me.At this point several questions arise.

1/ I notice that the PICKit demo program has two program files, one .ASM the other a 'C' program and also the Holy grail here an HEX output file. So question:

What program language do I start to learn Assembler code or C programming?

2/ I'd like for starters to write a program whereby I put 5v on input pin 4 and that makes an output pin 7 go +5v and lights an LED,no more complicated than that.

Can anyone point me in the right direction here?

All help really appreciated.

LEDave

I think there is a big problem in your MPLAB IDE software . Try to look for an IT expert. He can surely do it. :)

ScaleRobotics
- 13th June 2010, 16:08
I think there is a big problem in your MPLAB IDE software . Try to look for an IT expert. He can surely do it. :)

Are you sure you are just smoking tires? Have you read past post 1?

LEDave
- 13th June 2010, 21:23
Are you sure you are just smoking tires? Have you read past post 1?

Lol.......:)

LEDave
- 15th June 2010, 08:36
A couple of the best pictures from last night.

The 'device' is still working well.

I can't wait for the IF_Led array to arrive.

Dave

mackrackit
- 15th June 2010, 09:49
Those pictures are going to be hard to beat.

It almost looks like the badger is posing for you... Maybe it has figured out what you are up to.
Smile for the camera, free food. That has never worked for me...:confused:

LEDave
- 15th June 2010, 10:45
Smile for the camera, free food. That has never worked for me...:confused:

Me neither:( ...........Lol.

I am amazed at the results though. I'd like to lower the camera angle / height but doing so at the moment puts a lot of reflective flair into the pictures still, even with the diffuser. I'm really hoping the IR_Led array fixes everything.

I'm thinking of using another PIC pin set as an output to switch a transistor on and in turn switch a relay to drive the IR_Led array which is:"low power consumption - approximately 300mA". Does that sound like the best method to you?

The camera I'm using although very simple does have a 'movie mode' feature. I'm hoping to try and capture a short (the camera only takes 64MEG SD cards) 'Badger Movie'.

Dave

mackrackit
- 15th June 2010, 11:13
Maybe have a delay between the IR_array coming on and the camera trigger to give the camera time to adjust to the light... ??

LEDave
- 15th June 2010, 11:23
Maybe have a delay between the IR_array coming on and the camera trigger to give the camera time to adjust to the light... ??

Good thinking, it takes the camera a while to settle when I open the lens cover in daylight let alone pitch dark.I'll give it three seconds to start with then tweak it if necessary.

Dave

LEDave
- 16th June 2010, 15:05
The IR_Module has arrived.....Hoorah!

I've now got 32 LED's and eight resistors to solder into the board.....Booooo! (I didn't realise it was self assembly):eek:

Dave

mackrackit
- 16th June 2010, 21:38
Look on the bright side...
You did not order a mother board from that outfit....

LEDave
- 16th June 2010, 23:37
Look on the bright side...
You did not order a mother board from that outfit.............Lol, there is that.

I've just set up the camera for tonight's pictures, it's a nice still clear night here in the UK so fingers X'd.

If, when the IR_Illuminator is built and I manage to make a short movie, is it possible to upload the movie to this Forum or would that be to big?

Dave

mackrackit
- 16th June 2010, 23:42
Upload the video to youtube and embed it in the post.
The insert video icon above the reply box will be of help.

Good luck tonight.

LEDave
- 16th June 2010, 23:54
Upload the video to youtube and embed it in the post.
The insert video icon above the reply box will be of help.

Will do. I've never uploaded to youtube before, should be straight forward enough though. Yes the insert video URL will be good.


Good luck tonight.

Cheers.

Dave

LEDave
- 17th June 2010, 09:20
Another 57 photo's last night (the 16F684 is working well). We had the bonus of seeing the flashgun go off (1 am) and sneaked into the kitchen and watched him have his supper, really cool. It was amazing watching the flashgun fire and take picture after picture and the Badger wasn't bothered at all.

A real success this project, infrared here we come.

Dave

mackrackit
- 17th June 2010, 13:01
It was amazing watching the flashgun fire and take picture after picture and the Badger wasn't bothered at all.
Interesting.
Was you putting food out before you started this project?

Flash = Food

There was this fellow Pavlov.
http://www.age-of-the-sage.org/psychology/pavlov_conditioning_dogs.gif

LEDave
- 17th June 2010, 13:43
Interesting.
Was you putting food out before you started this project?

Yes, we were putting food for the birds (or so we thought) but going by last night's 'snack attack' by Mr B I think he's been having his fill for quite some time.

I can almost imaging the Badger doing a 'Pavlov' when he gets back to his home: Mrs B "Did LEDave have his flashgun setup tonight?" Mr B, "Yep, another maigraine with all those flashes, keeps us both happy though".......:)

Interesting stuff. I start soldering tonight.

IR_LEDave

Darrel Taylor
- 17th June 2010, 18:10
Is it me ... or is that badger getting FAT.
He looked a little skinnier in the first pictures.

Maybe you'll need to build a little treadmill for him too. :D

LEDave
- 17th June 2010, 19:30
Is it me ... or is that badger getting FAT.
He looked a little skinnier in the first pictures.

Hi Darrel,

I must admit 'portion control' has been a little lax of late. I'd reckon on about 1500 calories in last nights sitting.....;)

Dave

LEDave
- 17th June 2010, 23:31
Oh dear,

I've soldered up all 32 IR_Led's connected to the 12v battery (then after to a 12v power supply) and I doubt if I can see more than 15mm yet alone 15 meters:eek:

If I turn the array toward the camera then all 32 Led's can be seen but the illuminating power is pitiful.

The Led's don't look very bright compared to say a security camera's array (and I wasn't expecting it to really) but I can't see where they get their 15 meters from.

Any thoughts?

Dave

mackrackit
- 18th June 2010, 00:15
I see where the site says 5 meters and I would have guessed 2 or 3 but 15mm?

When they are connected to the power supply or battery what is the voltage of the supply?
Do you have an amp-meter? A fused one?

LEDave
- 18th June 2010, 00:35
Ah sorry it does say 5M.

Yes I do have an amp meter. The power supply voltage was 11.8v before I connected the circuit (I didn't check it after I attached the load, I should of and will in the morning), the power supply is rated a 2A.

I've just switched the power supply back to 5v for servo / camera for tonights pictures, what should I be looking for AMP wise?

Could I have the camera set up wrong? I can't see how really. At best I was getting a foot / 18" of illumination after a little fiddling.

Dave

mackrackit
- 18th June 2010, 00:56
The site said 300 ma.
Does you camera have a night setting? I am just guessing here.

LEDave
- 18th June 2010, 01:30
It has a 'Night scene mode" and you can adjust the white balance.

How bright would you think the Led's should be because they're pretty faint about a quaerter of what I'd expect.

mackrackit
- 18th June 2010, 01:44
They should be atleast as bright as your remote.

LEDave
- 18th June 2010, 08:20
Hi mackrackit

Well the power supply was showing .23/.24 of an amp at 11.9v and the battery .2 of an amp at 11.0v.

I'd say that each led in the camera viewfinder was as bright as a remote control led shows in the viewfinder.

Little bit of a mystery this one.

Dave

LEDave
- 18th June 2010, 08:30
I've just read this:


"also IR is only good on b/w camera's and some high end limited color cams"

Should my camera have been set to black and white?

david1800
- 18th June 2010, 12:30
Many digital cameras have IR blockers to prevent these wavelengths from interfering with autofocus etc. My experience is that there is a wide variation beween cameras but they appear, in my limited experience, to be moving to less IR sensitivity. However there are a few that advertise that they have night vision capabilities, for example some Sony models, and they achieve this by removing part of the IR block for very low light. So, you either need a higher power IR source, or a different camera if you need to capture with fast shutter speeds.

As far as setting the camera to B&W, I understand that this is done as part of the post capture processing so would probably not help.

Good luck

David


I've just read this:



Should my camera have been set to black and white?

LEDave
- 18th June 2010, 13:09
Thanks for that David.

It looks like I'm running out of options here.

I am surprised in that my camera is a few years old (six) and is non auto_focus, it's just a basic point and shoot camera.

I'll try it tonight in b&w mode just in case, fingers x'd.

Dave

LEDave
- 19th June 2010, 00:01
Well I set the camera up in b&w mode, only worked out to about a foot, shame I was looking forward to a 'stealth' Badger movie, but never mind.

I'll try and get hold of a more powerful illuminator one day.

Dave

LEDave
- 21st June 2010, 16:14
These look interesting for a 'project'.

http://uk.farnell.com/jsp/displayProduct.jsp?sku=1112743&CMP=e-2072-00001000

Works with the PICkit1 too.

Dave

mackrackit
- 21st June 2010, 22:12
That would be fun to play with. I have not used a RFPIC but have used other RF modules.
RF is a lot of fun. It would be worth learning.

LEDave
- 21st June 2010, 23:25
Is there any benefit of 315MHZ over 433MHZ?

I've read the Farnell Data_Sheet which is a little light on info. Any idea what kind of range these work over?

Dave

mackrackit
- 22nd June 2010, 11:22
Is there any benefit of 315MHZ over 433MHZ?
For the average user both frequencies will work about the same. Generally the higher the frequency the easier it is to to transmit through the typical Faraday cage (re-bar in walls) but 315 and 433 are pretty close.

I would expect around 1/2 mile line of site with these using a 1/4 wave whip antenna, good ground plane, and decent code. Of course the range is farther but it is harder to get reliable data the farther you stretch it.

Here is a code example that for the simplicity is very reliable.
http://www.picbasic.co.uk/forum/showthread.php?t=12554
I would think this code will work with the modules you are looking at.

LEDave
- 23rd June 2010, 00:39
Hi mackrackit,

Thanks for that. Half a mile line of sight is a good distance. I think I'll order up the 433 transmitter and receiver modules.

I had a look at Bruce's programs (he's one clever guy) there's lots there to learn about.

Hey maybe I could start by transmitting how many Badger pictures have been taking during the night (if any) and send the data to my LCD. That would save having to take the camera away from the cable release mechanism every morning only to find no pictures have been taken and then re_assemble it the next night (all very fiddly).

Some more interesting stuff to learn about, RF, I like it:D

Dave

LEDave
- 23rd June 2010, 14:51
update:

I've just ordered up the 433MHZ transmitter and receiver modules.

Dave

LEDave
- 23rd June 2010, 17:31
Questions:

1/ If you had two circuits, or more to the point two 433MHZ receivers in close proximity, would one transmitter interfere with or trigger both receivers?

2/ If the answer to Q1 is yes, is there anyway (either by software or physically) to slightly change a transmitter and receivers operating frequency to make them totally independent units?

Dave

mackrackit
- 23rd June 2010, 19:41
Q1 is yes.

Some modules can be set a little off frequency but most "hobby" types can not. I do not know if the RFPICS can be.

There are also encoder/decoder chips.

But I will say "normally" it is done in software.
Basically think of a computer network. Each device has an address.
If the packet does not have your address attached then the packet is ignored.

LEDave
- 23rd June 2010, 23:03
But I will say "normally" it is done in software.
Basically think of a computer network. Each device has an address.
If the packet does not have your address attached then the packet is ignored.

Cheers mackrackit, so it should be possible to send data only to a designated receiver module?

There is a reason I'm asking this.....Another project:D

The modules have been shipped today (very efficient I must say).

Dave

mackrackit
- 24th June 2010, 11:24
so it should be possible to send data only to a designated receiver module?
Yes and no...
When data is sent it is sent everywhere. It is up to the receiver to "decode" the signal. Even data that the receiver does not understand hits the receiver.

Think back to serial comms with wires. You have a "wait" for something before the receiver acts on the data. Pretty much the same with RF. But with RF there is noise from everywhere hitting the receiver.

Dig through the app notes from these folks
http://www.linxtechnologies.com/Support/Application-Notes/
AN-00160
AN-00232
AN-00500
AN-00501
Are some good one to start with.

LEDave
- 24th June 2010, 13:20
Dig through the app notes from these folks

Will do mackrackit, thanks for the info. My RF knowledge is less than my LED knowledge when I first came here right now......oh dear.

The Modules arrived today (I only ordered them yesterday) they came over from Belgium too. They are quite small (I was expecting them to be larger, I don't know why). I'll have a closer look when I get a minute / tonight.

RF is the 'Holy Grail' for me. If I can figure this one out then it's uses are nigh on endless.

Dave

LEDave
- 24th June 2010, 22:54
mackrackit,

Those notes are really interesting and informative, I'm working my way through them, cheers.

Dave

mackrackit
- 25th June 2010, 00:32
Next you will want to get a HAM licence :)

LEDave
- 25th June 2010, 14:08
Next you will want to get a HAM licence

Mmm............:)

LEDave
- 25th June 2010, 22:24
Problem?:

I'm thinking I should have ordered the: "rfPIC software and complete documentation (on CD)"?

There was no CD in either of the boxes. I'm thinking I'm up the creek without it? Or can I get by without the CD?

Sorry I know, more questions.

Dave

mackrackit
- 26th June 2010, 05:54
This might be a place to start
http://www.farnell.com/datasheets/309975.pdf

I have not used the rfPIC modules but I think we can figure it out. :rolleyes:

A quick look at the data sheet.
Header J3 in the PICKIT1 needs to be used after removing the chip from the evaluation socket. My PICKIT1 just has holes for J3, if yours is that way you will need to bring wire off it to a bread board. Looks like J3 pin#1 is on the edge of the board.

Then after the module is programed it should be able to "stand alone" on the bread board.

LEDave
- 26th June 2010, 10:41
Hi mackrackit


This might be a place to start
http://www.farnell.com/datasheets/309975.pdf

Absolutely, I tracked down the Microchip.pdf (same one I think) anyway my PICkit1 does have header J3 on it, so that's a help.

I spent ages last night mulling over how all this might work and it seemed to me that I either:

1/ I need two PICkit1 boards one for the TX and one for the RX.

2/ The TX is 'stand_alone' with a battery fitted - However, the TX has a socket for a 12F675 (you have to break some tracks for this to work I think) So I'm not sure if the TX will work without the 12F675 and tracks broken in some kind of test mode (if that makes sense). Or will only work as 'stand_alone' with a program loaded into the 12F675 and tracks broken.

Dave

mackrackit
- 26th June 2010, 13:43
Both modules are stand alone. The 8 pin socket on the transmitter is optional. I would not cut anything at the moment.

It is my understanding that the rfPIC12F675 is just a 12F675 with RF on board, plugging the modules into the PICKIT1 is just a way to program them.

I bet the software for the PICKIT1 sees the modules as is. Have you plugged either one into the PICKIT1 yet?

One the modules are programed you should be able to power them with out the programmer attached.

Maybe...

LEDave
- 26th June 2010, 16:06
Both modules are stand alone. The 8 pin socket on the transmitter is optional. I would not cut anything at the moment.

:D:D Really pleased to not have to cut the tracks, I was dreading that job!


I bet the software for the PICKIT1 sees the modules as is. Have you plugged either one into the PICKIT1 yet?

No I haven't plugged either into the PICkit1 as yet. The TX has a battery holder for a round CR2032 battery (which I don't have), I'm thinking if I got one of these (tomorrow) for the TX and plugged the RX into the PICkit1 we have two fully powered TX_RX circuits. How does that sound?

Dave

mackrackit
- 26th June 2010, 16:50
That should work.
It also looks like it you leave the program power jumper on you should be able to power the transmitter while in a breadbord from any 2 to 5 volt source.
Not sure how long the coin battery will last.

LEDave
- 26th June 2010, 20:43
It also looks like it you leave the program power jumper on you should be able to power the transmitter while in a breadbord from any 2 to 5 volt source.

I saw that, very handy. It would be good to buy a few expansion headers (J3) as well if I can source them, rather than solder the actual modules onto a vero board.The TX module won't push into my breadboard either (a real shame that) as the pins lie flat against the circuit board, again a J2 header would have solved that, never mind.

I'm so keen to try these modules out that I've been seriously thinking of soldering the TX module to a vero board and running a power supply to it but after a rush of blood I've decided to get the battery tomorrow and have TX stand alone using the battery and RX in the PITkit1.

Roll on tomorrow.

Dave

PS: The Badger hasn't made an appearance for three nights in a row now, we're a little worried for him....

LEDave
- 27th June 2010, 17:27
I've bought a 3v battery for the TX and fitted it, a red LED blinks when either push button switch 1 or 2 is pressed, so seems to be working.

As for the the RX module (I haven't inserted this yet), the evaluation socket is empty and the PIC16C745 Firmware chip is still in place. I'm tempted to insert the RX module into the J3 Header but haven't.

Not sure what to do next.

Dave

LEDave
- 27th June 2010, 17:56
This is what microchip has to say:

http://ww1.microchip.com/downloads/en/DeviceDoc/70092a.pdf



1.3 GETTING STARTED WITH THE rfPIC DEVELOPMENT KIT 1
The transmitter modules come pre-programmed with a transmitter demonstration. The
enclosed PIC16F676 is programmed with a receiver demonstration program. Together
they demonstrate an on-off command and control application.
The PICkit 1 FLASH Starter Kit serves as a low-cost development and demonstration
platform for the transmitter and receiver modules.
To see your rfPIC Development Kit 1 in action, perform the following steps:
1.3.1 Preparing the Receiver Module for Operation
Step 1:
Familiarize yourself with the PICkit 1 FLASH Starter Kit operation by reading the
PICkit™ 1 FLASH Starter Kit User’s Guide (DS40051) and performing some of the
tutorials. Familiarity with the PICkit Starter Kit will be assumed throughout this user’s
guide.
Step 2:
Remove power from the PICkit Starter Kit by disconnecting the USB cable.
Step 3:
Remove the PIC12F675 from the PICkit Starter Kit evaluation socket.
Step 4:
Insert the PIC16F676 into the PICkit Starter Kit evaluation socket. See Figure 1-1.
Step 5:
Insert a receiver module (315 or 433.92 MHz) into the PICkit Starter Kit expansion
header J3. Make certain that the receiver module is oriented correctly. See Figure 1-1.

So it looks to me that if I'd have bought a complete rfpic development kit it would have come with a PIC16F676 programmed with a receiver demonstration program. So the TX has a demo program installed but I haven't got a PIC16F676 for the RX with a demo program.

mackrackit
- 27th June 2010, 18:07
I have not had time to look into this very much but some demo programs can be found here. In ASM though.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010060

LEDave
- 27th June 2010, 18:36
Cheers mackrackit,

I'll have a look and a tinker (tinker is that an engineering term...;)) and report back.

An RF_LED_Blink program would do for me right now.

Dave

LEDave
- 27th June 2010, 20:54
I found this RX_Demo program for the rfpic, only thing is it says 16f675 again, so no joy so far.


Filename: rcvr_demo.asm
; Date: April 25, 2003
; File Version: 1.0
; Assembled using:
;
; Author: Steven Bible
; Company: Microchip Technology Inc.
;
;
;----------------------------------------------------------------------
;
; Files required:
; p16f676.inc

mackrackit
- 28th June 2010, 18:45
Did some more poking around.
If you have not seen these they will be helpful. Data sheets for the actual chip on the modules.
http://ww1.microchip.com/downloads/en/DeviceDoc/70090a.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/70091a.pdf

As you know the transmitter is programmable and it appears that both modules are pre configured for ASK modulation.

You can find out more about modulations here.
http://davehouston.net/RFTipsTricks.htm
Dave has a whole lot of good info on his site.
http://davehouston.net/

Looks like you can use pin #11 from the receiver module to connect to any PIC for serial data so the code that Bruce posted can be used.

LEDave
- 28th June 2010, 21:02
Thanks for the info mackrackit, the TX does work, the doorbell has rung several times now when the TX is pressed:eek: Still no blinking LED though, will get there though.

Dave

LEDave
- 28th June 2010, 23:18
Well I've spent most of this evening loading demo programs into the TX and RX, and doing a lot of reading, still not a blip or lit LED in sight........:(

Dave

LEDave
- 29th June 2010, 18:29
I'm thinking I need to go back to my MPLAB IDE and figure out how to convert an Assemler program to a HEX file and load that into my RFPIC TX and RX.

The words Assembly language and Dentist have exactly the same effect on me and I don't like either. The first because I'm not clever enough to understand it fully and the second because I do......:rolleyes:

It's a shame there's not a MCS_RF section........Grrr.

Dave

mackrackit
- 30th June 2010, 11:13
Check this out. Bruce to the rescue... Again
He is using a 676 connected to the receiver but you should be able to adapt the receiver code to whatever you have.
http://www.picbasic.co.uk/forum/showthread.php?t=7241&highlight=rfPIC

LEDave
- 30th June 2010, 22:15
Cheers mackrackit (and Bruce).

I'll have a go over the next day or two and report back.

I've got my first RF project lined up: A friend of mine and a keen clay pigeon shooter wants to be able to fire his clay trap by remote control instead of a long wire. I told him I'll have a go, just give me six Months, he says there's no rush, just as well:eek:

Dave

LEDave
- 1st July 2010, 22:15
Hi mackrackit,

I've had a: " Small breakthrough for mankind, a giant breakthrough for me" evening.

I've managed to get the Demo_prog to run. LED's D0 & D1 light when the push buttons are pressed, so very pleased with that.

The TX range was a little on the low side at about 50 yards, 200 would be fantastic. I'm going to make a stand alone receiver board next and see how that goes.

Always good to get something working:)

Dave

mackrackit
- 2nd July 2010, 00:29
COOOOL!!!

Range-- What are you using for an antenna?
1/4 wave (6.5 inches) wire over a ground plane?

LEDave
- 2nd July 2010, 03:11
Range-- What are you using for an antenna?

At the moment it's a single wire (AWG 24) approx 6.5" long.

The booklet says: "Alternatively, the pin receptacle can be removed and an alternative antenna connection can be made. For example a coaxial wire can be connected to the antenna pad on the front side of the pcb and ground pad on the back side of the pcb."

Early days yet but would one of these be any better?

http://www.maplin.co.uk/Module.aspx?ModuleNo=35648

Dave

mackrackit
- 2nd July 2010, 06:01
For something permanent that would be good, but you still need a ground plane with any 1/4 wave antenna.
For prototyping I use a wire stuck into a bread board with the bread board setting on an aluminum plate. The plate is connected to ground (zero rail).

http://www.arrl.org/files/file/Technology/tis/info/pdf/6201025.pdf
http://www.arrl.org/files/file/Technology/tis/Why%20an%20Antenna%20Radiates.pdf

LEDave
- 2nd July 2010, 15:11
For something permanent that would be good, but you still need a ground plane with any 1/4 wave antenna.

I remember reading somewhere that for a 1/2 wave antenna you don't need a ground plane, is that an option here?


For prototyping I use a wire stuck into a bread board with the bread board setting on an aluminum plate.

Is the wire then attached to the plate or the RX device?

Dave

mackrackit
- 2nd July 2010, 16:29
I remember reading somewhere that for a 1/2 wave antenna you don't need a ground plane, is that an option here?
Yes but it will basically need two 1/4 wave wires. the ground plane sorta takes place of the second wire. 1/2 wave has advantages but for a portable the 1/4 wave is the most practical.


Is the wire then attached to the plate or the RX device?
The wire is the 6.5 inch antenna. 4587
Using the above setup I can get .5 mile line of site with these.
http://www.rentron.com/remote_control/TWS-434.htm
http://www.rentron.com/remote_control/RWS-434.htm

LEDave
- 2nd July 2010, 19:04
I see, does it have to be an aluminium plate or would a good size piece of vero board be ok.

I liked those RENTRON TX_RX modules, I don't think for one moment they'd ship to the UK? Probably cost too much in postage, then again the module price was excellent.

Dave

mackrackit
- 2nd July 2010, 19:11
I see, does it have to be an aluminium plate or would a good size piece of vero board be ok.
Has to be electrically conductive.
Probably find something in the kitchen that would work.... :p

LEDave
- 2nd July 2010, 19:36
Probably find something in the kitchen that would work.... :p

I've just tried a small aluminium vice from the shed and an aluminium tray (from the kitchen funnily enough ) the vice added another 5 - 10 yards, the tray not so much. I had a few funny looks from the neighbours every time I waved back at Mrs LEDave to say an LED had blinked as I walked up the street.

I'm sure the distance can be boosted with some more tweaking.

Dave

mackrackit
- 2nd July 2010, 20:02
I had a few funny looks from the neighbours
My neighbors moved... :eek:

The antenna is half of the radio. It is the one part that is easy to tweek.
If you really want to get into antennas the arrl.org site has a ton of info. I keep the ARRL Antenna Handbook close. About as bad as a data sheet though, 900+ pages of good info.

LEDave
- 2nd July 2010, 20:11
My neighbors moved :eek:

Lol....:D:D.

Well I'm just after a couple of hundred metres, I'm sure we'll get there.Thanks for the antenna link.


My neighbors moved

Cracking.

LEDave
- 5th July 2010, 20:14
I'm having problems compiling Bruce's program and I keep getting the two error messages below:


Found label after column 1 (Device) Illegal opcode PIC16F676) & Illegal opcode (PWRT_ON)

I had this once before with one of my programs, it turned out I had the wrong PIC selected from the drop down list but I haven't this time.

Any ideas?

Dave

ScaleRobotics
- 5th July 2010, 22:07
It does not like the way configs were defined:


@ DEVICE PIC12F675,MCLR_OFF,INTRC_OSC_NOCLKOUT,WDT_OFF,BOD_ OFF
@ DEVICE PWRT_ON,PROTECT_OFF


And some of the names of the registers needed some "E" 's added to them.

Try this instead:



@ __CONFIG _MCLRE_OFF & _INTRC_OSC_NOCLKOUT & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _CP_OFF


Walter

mackrackit
- 5th July 2010, 22:15
And..
Bruce is using PM for an assembler in that example.

LEDave
- 5th July 2010, 22:43
Thanks for that Walter.

Hi mackrackit,

Tonight's silly question: What's PM? Is that a Microchip assembler?

Dave

mackrackit
- 5th July 2010, 22:58
PM is the assembler from the Pic Basic folks. It works well on the older and smaller chips.

MPASM from MicroChip works for everything.

LEDave
- 5th July 2010, 23:14
MPASM from MicroChip works for everything.

So a program written in PBPro would compile and run using the MPLAB IDE?

Or am I North of the North pole.....again?

Dave

mackrackit
- 5th July 2010, 23:24
You are still some what south...

MPLAB or MCS will work. So will a simple text editor. For writing code that is. I find myself using gEdit or EMACS more often than not.

Once the code is written the compiler/assembler can then be ran.

Do you remember *.bat files??

LEDave
- 6th July 2010, 00:33
Do you remember *.bat files??

Yes, Batch files, small text file program commands... cmd.exe.

mackrackit
- 6th July 2010, 00:46
Here is the guts of a BAT

cd
cd C:\MAC\PIC_PROGS\PPPBP\test_prog\
PBPL -e -ampasmwin -p18F4550 test.bas
cd\
It is just the command line stuff that the manual talks about. It is really nice having the command line option for PBP.

LEDave
- 6th July 2010, 15:50
Hi mackrackit,

I had a read of the manual dinner time today (right at the beginning).

So what we're saying here is that you can use most text editors to write the code and then 'invoke' the compiler to then create the HEX file and away you go.

Dave

mackrackit
- 6th July 2010, 19:46
Yes.

I do like text editors with syntax highlighting but even windows notepad will work. If I remember correctly that is what Melanie uses, just plain 'ol notepad.

LEDave
- 6th July 2010, 22:46
If I remember correctly that is what Melanie uses, just plain 'ol notepad.

Goes to show then...........:)

Dave

Ah, almost forgot, the Badger re-appeared last night I'm very pleased to say.

LEDave
- 8th July 2010, 00:18
Below is a part of a simple little program I've been experimenting with to generate a 'random' pause but of known maximum and minimum time period(average maximum wait about 12secs for the LED to flash as the program stands).

The pause occurs randomly but because there are a maximum of 65535 'lenghts' if you will of a given time (be it clock cycles etc (I'm not sure how RANDOM works) it should be possible to my mind to work out how long the longest and shortest pause times will be when they occur (1 or 65535 lenghts) I think.

So my question is this: How long does it take the PIC processor to calculate 1 lenght? At the moment the maximum and minimum pause times occur at 12secs max 1sec min.

I hope this makes sense


X VAR WORD

main:
RANDOM x

PAUSE X /4

HIGH PORTA.2
PAUSE 1000
low PORTA.2
GOTO MAIN:

Dave

mackrackit
- 8th July 2010, 12:28
Can you setup a LCD or have the value of x sent to a terminal? I would think you should have at times a longer pause than 12 seconds??

You may want to look at this also.
http://www.picbasic.co.uk/forum/showthread.php?t=9350

LEDave
- 8th July 2010, 21:21
Hi mackrackit,

I've been working really hard on this. I've taken your idea of:


Can you setup a LCD or have the value of x sent to a terminal?

And done this:

What I've done is change the original code to measure the time the LED is on rather than measure the time the program was 'PAUSED' because to my mind you can only use 'PULSIN' on a active pin. I've then tried to output that 'PULSIN' number using 'SEROUT2' to the Serial communicator.

It nearly works I think, what it does is output a series of zeros, instead of the time in micro_secs. I suspect I've made an error here:


SEROUT2 PORTC.3, 16780, [DEC Z, 10 ,13] 'The measured RANDOM time sent to S/Communicator

I think it could be the Decimal value of Z that's causing the problem (I hope) being as it should be measuring in blocks of Micro_secs.

Here's the program, I feel I'm close, but am I?. If you could look the program over and give me a pointer that would be really appreciated. The chip is a 16F684.



ANSEL = %00000000 'Disable analog select so ports work as digital i/o.
CMCON0 = %00000111 'Disable analog comparators.
TRISA = %00000000 'Set PORTA as OUTPUT.
PORTA = %00000000 'Set PORTA pins all low.
TRISC = %00000000 'Set PORTC as OUTPUT.
PORTC = %00000000 'Set PORTC pins all low.

DEFINE OSC 4


X VAR WORD 'Number between 1 & 65535
Y var WORD 'Scaled down value of X
Z VAR BYTE 'The PAUSED value of Y in 10us Increments

main:
RANDOM X 'Random number between 1 & 65535
LET Y = (x /14) 'Scaled down value of X
HIGH PORTA.2 'LED PORTA.2 lights up
PAUSE Y 'LED on for time period of RAN_X_OVER_14
PULSIN PORTA.2,1,Z 'The paused RANDOM time period stored in VAR Z
SEROUT2 PORTC.3, 16780, [DEC Z, 10 ,13] 'The measured RANDOM time sent to S/Communicator
'in 10us incremets
low PORTA.2 'LED off
GOTO MAIN: 'Do it all again

Dave

LEDave
- 8th July 2010, 22:32
Ah, have I got 'PULSIN' in the right place in the program? Might it be better in front of HIGH PORTA.2 ?

Nope, still outputting zero's.

The manual says of zero's:


If the pulse edge never happens or the width of the pulse is too great to measure, Var is set to zero

Now I'm thinking the pulse must happen because the LED lights and with a 'RANDOM' delay but could it be to big to measure?

How big is too big to measure for a pulse?

Dave

mackrackit
- 9th July 2010, 01:31
As far as I know PULSIN is for reading a pulse on a pin from the outside not a pulse from the inside.

It has been a long day so maybe I am missing something... What exactly are you wanting to do?

HenrikOlsson
- 9th July 2010, 07:01
Hi Dave,
I see you've been making a lot of progress, good job!

Remember that PBP executes one statement at the time. In this case you set the pin high, then you pause, then you start the pulsein statement which waits for a positive going signal which isn't coming since the pin is already set high so it times out and returns zero.

On top of that, as Mackrackit says, PULSIN is meant to be used on pins configured as inputs, I'm not sure if it works like you have it.

And, why do you need to measure it? Why not simply "print" the value returned by the RANDOM command? I mean PAUSE works with units of ms if RANDOM returns 100 you divide that by 14 and get 7 so you'll get a pause of 7ms, if RANDOM returns 34567 you divide that by 14 and you'll get 2469ms pause. I don't see the point in trying to measure that but if you really need to do that then look into using one of the PICs hardware timers. Reset it, set the pin high and start the timer. Pause x, set the pin low, stop the timer and read its value.

/Henrik.

LEDave
- 9th July 2010, 13:11
Hi Henrik,

Sorry for the late reply.


I see you've been making a lot of progress, good job!

That'll be down to mackrackit, yourself and a few others, thanks for sticking with me, it's very much appreciated.


Remember that PBP executes one statement at the time. In this case you set the pin high, then you pause, then you start the pulsein statement which waits for a positive going signal which isn't coming since the pin is already set high so it times out and returns zero.

I was running the program through my mind as I was going of to sleep last night and realised
just that.


On top of that, as Mackrackit says, PULSIN is meant to be used on pins configured as inputs, I'm not sure if it works like you have it.

Another mistake, I got the PULSIN idea into my mind and rushed to write some code and overlooked setting the the REGISTER pin to INPUT.Good practice would be to set the I/O REGISTER then start writing code, I'll try and stick with that from now on.


And, why do you need to measure it? Why not simply "print" the value returned by the RANDOM command?

Another gap in my knowledge base I'm afraid, I didn't know you could 'print' the value.


PAUSE works with units of ms if RANDOM returns 100 you divide that by 14 and get 7 so you'll get a pause of 7ms, if RANDOM returns 34567 you divide that by 14 and you'll get 2469ms pause.

Spot on Henrik, just what I needed to know.

I'm trying to write a program for a project which must have a RANDOM delay of zero to three seconds.

So how about this:

65535 / 21.845 gives 3000ms as a Maximum value. Any number generated will be lower than 65535 therefore shorter than 3 seconds!



ANSEL = %00000000 'Disable analog select so ports work as digital i/o.
CMCON0 = %00000111 'Disable analog comparators.
TRISA = %00000000 'Set PORTA as OUTPUT.
PORTA = %00000000 'Set PORTA pins all low.
TRISC = %00000000 'Set PORTC as OUTPUT.
PORTC = %00000000 'Set PORTC pins all low.

DEFINE OSC 4


X VAR WORD 'Number between 1 & 65535
Y var WORD 'Scaled down value of X
Z VAR BYTE 'The PAUSED value in 10us Increments

main:
RANDOM X 'Random number between 1 & 65535
LET Y = (x /22) 'Scaled down value of X
PAUSE Y 'LED on for time period of RAN_X_OVER_22
HIGH PORTA.2 'LED PORTA.2 lights up
PAUSE 500
low PORTA.2 'LED off
GOTO MAIN: 'Do it all again

Dave

LEDave
- 9th July 2010, 13:20
Another quick question:

I've rounded up the Value 21.845 to 22 see below


LET Y = (x /22) 'Scaled down value of X

When I used the value of 21.845 and try and compile it I get an error saying bad variable modifier. Is there any way of making the program use 21.845 for super accuracy?

Dave

HenrikOlsson
- 9th July 2010, 13:30
Hi Dave,

Another gap in my knowledge base I'm afraid, I didn't know you could 'print' the value
Sure, the value returned by Random is just as any other variable stored in WORD size variable.

That should work. Obviously you'd have to change Pause 500 to Pause Y. Another small note, there's really no need for the Y variable in this case, it's perfectly OK to do:

TRISA.2 = 0
Random X
SEROUT 2 PORTC.3, 16780, [DEC X, 13, 10] 'Send value out
X = X / 22 'Scale down, no need for the Y variable.
PortA.2 = 1
Pause X
PortA.2 = 0

I remember reading that RANDOM in reality is far from that. Being given a certain seed it returns the same "random" number, in the same order every time the program is run, or something like that. Search the forum a bit and I believe you'll find some info regarding that.

/Henrik.

mackrackit
- 9th July 2010, 13:51
http://www.picbasic.co.uk/forum/showthread.php?t=12526&highlight=random+seed

An MCU does not handle anything other than integer math with out some heavy manipulation. Most times it is better to find away around using decimals. So in your case I would stick with 21.

Or you could dive into this
http://melabs.com/resources/fp.htm

HenrikOlsson
- 9th July 2010, 14:20
Hi Dave,
I missed that second post of yours but Mackrackit covered it. The PIC only deals with integer numbers but there are several tricks around that, here's one:

X VAR WORD
Random X
X = X * 1000
X = DIV32 21845
SEROUT2, PORTC.3, 16780, [DEC Y, 13, 10]

As you can see here, the X = X*1000 most likely produces a result that won't fit within a WORD, however PBP (even before the arival of LONG variable) allows you to use the intermediate 32bit result for calculations like this one. So, we multiply X by 1000 and then divide it by 1000*21.845 which is the same as dividing X by 21.845 in the first place. It will truncate whatever is to the right of the decimal point but in this case it means that you'll be off by no more than 1ms.

Thanks Mackrackit for digging up the posts on RANDOM!

/Henrik.

LEDave
- 9th July 2010, 15:14
Too clever by half you two......;)

No seriously great stuff and a great help. Henrik thanks for code, looks just the ticket.

So RANDOM isn't really RANDOM, only a pseudo RANDOM. Which gives me another small problem. I don't want the 'seed' to start in the same place when the PIC is powered up and run.

Is there a way of starting the 'RANDOM' cycle with a different 'seed' at power_up each time?

Dave

HenrikOlsson
- 9th July 2010, 15:58
Hi Dave,
I was sure you could specify the "seed" but a look in the manual shows I was wrong :-( Anyway, it would only "offset" you into the predermined list of "random" numbers as explained in the thread Mackrackit linked to. There are a couple of ideas in that thread bu I don't currently have any good advice regarding that.

There's a small typo in the example code in my previous message but I'm sure you spotted that.

/Henrik.

mackrackit
- 9th July 2010, 16:19
If you want to play with the hardware...
Have a momentary start push button that triggers a mosfet to start the PIC. When the PIC starts a pin will keep the mosfet triggered. To kill the PIC another momentary push button will break the gate signal to the mosfet.

WHILE
the start push button his held "down" to start the PIC it also brings another pin HIGH.
RANDOM X
WEND
GOTO MAIN PROG

Kinda sounds like something Goldberg would do :p

LEDave
- 9th July 2010, 20:45
Where to start?


There's a small typo in the example code in my previous message but I'm sure you spotted that.

Hi Henrik, at first glance, should that be:


[DEC X, 13, 10] instead of Y ?


Kinda sounds like something Goldberg would do

Hi mackrackit, who's Goldberg? The hardware idea looks interesting, something to think about there.

I've just ran the RANDOM / 22 SEROUT2 through the serial communicator with a 1 second pause between outputs so I read the values, absolutely brilliant to see, highest value I read was 2977 milli_secs so pretty good. I'll run Henriks a little later tonight when I get a minute.

Brilliant stuff this,thanks again.

Dave

LEDave
- 10th July 2010, 00:25
I'm truly amazed tonight:):):)

I've managed to get Henriks DIV32 program to run and the accuracy is absolutely spot on! And I mean absolutely spot on!

I wanted a program that could PAUSE randomly within a period of 1ms to 3000ms.

Here's part of the code:


main:
Random X
Y = X * 1000
Z = DIV32 21845
SEROUT2 PORTC.3, 16780, [DEC Z, 13, 10]
IF Z = 2997 THEN STOP
IF Z = 2998 THEN STOP
IF Z = 2999 THEN STOP
IF Z = 3000 THEN STOP
IF Z = 3001 THEN STOP
GOTO main


To test it I ran it through the Serial Communicator with no pauses to speed the runs up and set up a series of IF_THEN_STOP statements if any of the conditions were met. Sure enough 2997,2998 and 2999ms were within the program range and stopped the program.

Then for the big one 3000ms, that was also there and stopped the program!

What about 3001.....Nope, the program runs from 1 to 3000ms absolutely stop on.

Henrik, mackrackit, thank you both and good night.

Dave

mackrackit
- 10th July 2010, 03:12
http://en.m.wikipedia.org/wiki/Rube_Goldberg?wasRedirected=true

HenrikOlsson
- 10th July 2010, 07:56
Hi Dave,

It can't ever be more than 3000ms because the highest value possibly returned by Random is 65535, anything larger won't fit in the WORD variable. We multiply that by 1000 and divide it by 21845 resulting in 3000. So, with these numbers it's simply impossible to get anything "larger" than 3000.

/Henrik.

LEDave
- 10th July 2010, 08:56
Goldberg is best known for a series of popular cartoons he created depicting complex devices that perform simple tasks in indirect, convoluted ways.

Me and Rube have a lot in common, he draws them and I make them:)


It can't ever be more than 3000ms because the highest value possibly returned by Random is 65535, anything larger won't fit in the WORD variable. We multiply that by 1000 and divide it by 21845 resulting in 3000. So, with these numbers it's simply impossible to get anything "larger" than 3000.

Hi Henrik, I can appreciate that, I thought it was just cool to be able to see the numbers via the Serial Communicator.

What did you think of the way in which I made the program run using VARS: X,Y and Z?

Dave

HenrikOlsson
- 10th July 2010, 09:52
Hi Dave,
Nothing wrong at all with the way you did it. However, it seems to me you are "wasting" four bytes of RAM with the use of Y and Z. If you don't need to massage the intermediate results it's perfectly OK to simply use a single WORD variable, like

X VAR WORD
RANDOM X
X = X * 1000
X = DIV32 21845
SEROUT2 PORTC.3, 16780, [DEC X, 13, 10]

/Henrik.

LEDave
- 10th July 2010, 10:13
Hi Henrik,

Here's a strange thing (and I'll re-check this later). I originally ran the code as yours above and the output was something like: 2411-341-11-0-0-0-0-0. After only a few cycles it started outputting zero's.

I may well have made a 'typo' myself here so I'll re-check and re-run later today.

Dave

HenrikOlsson
- 10th July 2010, 11:18
Hi Dave,
Actually, it looks like you got me on this one... I'll HAVE to start verifying what I write before trying to look like I know what I'm talking about ;-) Don't know what's going on here, I'll have to try a few things out.

/Henrik.

EDIT: OK, I'm not sure exactly what's going on but this does seem to work:

RANDOM X
Y = X * 1000
Y = DIV32 21845
Thanks Dave for catching that and letting me know!

mackrackit
- 10th July 2010, 11:39
Henrik,
I think our student has been reading the manual and caught the "dummy" var in the examples given.

I think our student has also increased in rank!
Maybe now he is
NEWBIE.2
:)

LEDave
- 10th July 2010, 13:05
:):)mackrackit.


I think our student has been reading the manual and caught the "dummy" var in the examples given.

It was reading the DIV32 example that made me use the X,Y,Z VARS. Although I must fess_up and say that I wasn't 100% sure I'd spotted the 'right' typo in Henriks post.


I think our student has also increased in rank! Maybe now he is NEWBIE.2

Lol, I'm getting better but maybe NEWBIE1.5.......;)

Dave

LEDave
- 12th July 2010, 15:39
Following on from and using the theory we've already covered. I thought it might be a good idea to try and make the RANDOM time pause generated from the previous program slightly more RANDOM.

I noticed with the last program that RANDOM always 'seeded' with the same start value at power up a (2522_Mili_secs) pause and then followed the same number sequence on the display. So if you powered up and powered down the program in fairly quick succession you'd soon notice the start sequence wasn't that RANDOM at all, it was exactly the same!

So I got to thinking what if, when the program 'powered down' I saved the last RANDOM value in EEPROM memory and then re-loaded that value as the start 'seed' on 'power up' that would then continue the 'RANDOM' sequence (ok, RANDOM from 1-65535) so pretty RANDOM unless you're a memory man.

Here's the code I came up with (I changed from the Serial Communicator to LCD (why not, all good practice)). It seems to work too:).
The program continually WRITES to EEPROM whilst the program runs but only READS from EEPROM on power_up. What do you think?

CODE:


X VAR WORD
Y VAR WORD
Z VAR WORD 'STORED IN EEPROM LOCATIONS 0 AND 1

Start:
goto Power_up: 'Load STORED last RAND_VAL


Power_up: 'Power_up subroutine
Read 0, Z.HIGHBYTE 'Read VAL_Z_high byte
Read 1, Z.LOWBYTE 'Read VAL_Z_low byte
LET X = z 'SEED X with the VAL Z
GOSUB RAN:

RAN:
Random X 'RANDOM program cycle continues
Y = X * 1000
Z = DIV32 21845
LCDOUT $FE,2,"MSECS=",DEC4 Z 'LCD displays RAND_VAL
PAUSE Z 'Program PAUSES for 'Z_Mili_secs'
HIGH PORTA.2 'LED PORTA.2 lights up
PAUSE 500
low PORTA.2 'LED off
WRITE 0, Z.HIGHBYTE
WRITE 1, Z.LOWBYTE
GOTO RAN

Dave

HenrikOlsson
- 12th July 2010, 17:13
Hi Dave,
A couple of small things noticed:
1) You can read the value direct into X instead of first reading it to Z and then copying it to X. Nothing wrong with what you're doing it'll just save some program space and time.

2) The line GOSUB RAN: looks strange. First, there shouldn't be any colon after the label in the jump statement, only where you declare the actual label. Second, you don't want to GOSUB a routine from which you don't RETURN. In this case it may work but it's generally a bad idea.

3) Speaking of GOSUB and GOTO, you are making a couple of unneccessary jumps. At the beginning you say GOTO Power_Up even though the next line in the program is the beginning of the Power_Up routine. Same thing when Power_Up is done, then you jump to RAN which already is the next line so it will get there without needing to jump to it.

Now, if you have some other code "in between" then it makes sense, and as you've found it, it works the way you have it but it's not needed.

4) The EEPROM has a limited number of write-cycles. We're talking tens or even hundreds of thousands of cycles but if you write to it on average ever 1500ms, 100.000 writes are less than 42 hours.

There are ways to get around that but it requires a little hardware and the use of interrupts. Basically you have a capacitor that allows the PIC to stay powered long enough to make the EEPROM writes. The capacitor is charged from your powersupply thru a diode. Then you have a "direct" wire going to an input on the PIC which fires an interrupt when the powersupply goes down (the cap is keeping the PIC alive).

Again, just a couple of small things to consider. Good job!

/Henrik.

LEDave
- 12th July 2010, 20:47
Thanks for the pointers Henrik. Some lax programming there to say the least, I do agree. I'll have to sharpen things up. I did have a push button loop in there at one stage IF - THEN - LABEL but took it out and in my rush / excitement to get the program to work made things look untidy.


4) The EEPROM has a limited number of write-cycles. We're talking tens or even hundreds of thousands of cycles but if you write to it on average ever 1500ms, 100.000 writes are less than 42 hours.

I remember mackrackit commenting on the write cycles of an EEPROM, I was mindful of that, again my rush to get it to work overroad it and I looked the other for now.

To be honest I was pleased that the write to EEPROM idea worked (or seemed too).

Thanks again.

Dave

mackrackit
- 12th July 2010, 21:41
Use the EEPROM idea but write to the EEPROM once during run time.

But before you write Z, maybe add 37 or something to it.

LEDave
- 12th July 2010, 23:14
Use the EEPROM idea but write to the EEPROM once during run time.
But before you write Z, maybe add 37 or something to it.

Now why couldn't I have thought of that.....:(

I went to use the rfpic transmitter the other day and the battery was flat, would the module continually be draining power with the battery in place or was it just that the battery was unused but old do you think?

Dave

mackrackit
- 12th July 2010, 23:33
The EEPROM thing was your idea... ;)

Sounds like a weak battery or the transmitter was stuck on transmit.
Can you check the amps when "not in use" ?

LEDave
- 13th July 2010, 00:54
Sounds like a weak battery or the transmitter was stuck on transmit.

I'm hoping the former.The battery I used was unopened but had been my draw for a long, long time.


Can you check the amps when "not in use" ?

Tricky and I guess I'll need a new battery which I don't have right now. I guess try a new battery.

I read in the TX pdf that the TX output power can be set and adjusted via different resistor values set on a pin. This might be a way of increasing the transmit range (at the cost of battery power/life I guess).

Here's (another) project I'd like to do next Spring (gives me time to learn how to do this). Most Years we have birds use a nesting box in our apple tree. When the young hatch, the parents are really busy bringing in food. I'd like to:

1/ Have a beam set across the entrance whole to the nest box.

2/ When the beam is broken (parent bring in food) a counter is incremented and stored.

3/ Set a Light_Dependant_Resistor up so that when night falls the days DATA is rfpic'ed back to the RX module and displayed on the Serial Communicator.

LEDave, so many projects, too little knowledge.

mackrackit
- 13th July 2010, 01:09
Cool project!!!
Two beams so you only count one way? Or just divide by two?

LEDave
- 13th July 2010, 01:44
Two beams so you only count one way? Or just divide by two?

Mmm, I hadn't thought of that. I guess divide by two would be easiest, all depends on space I guess.

Looking at the TX / RX demo code in.ASM it looks really difficult and Bruce's code not much easier, although I can understand some of that, would be good to try and figure and learn over the Winter.

To my mind, sending data through the air has something mystical / magical even about it. I'd like to crack rf.

Right, I'm off to me bed.

Night, night mackrackit.

Dave

mackrackit
- 13th July 2010, 15:02
Looking at the TX / RX demo code in.ASM it looks really difficult and Bruce's code not much easier, although I can understand some of that, would be good to try and figure and learn over the Winter.
You will get it.. Plenty of resources here.
But you may want to start a new thread specific to the project. This one has gotten all over the place...

LEDave
- 13th July 2010, 16:00
You will get it.. Plenty of resources here.

Would be go if I could. Like I said when I first joined the Forum: I may not be that brightest but I am a trier:)


But you may want to start a new thread specific to the project. This one has gotten all over the place...

Fair comment mackrackit. I'll do my background research into rf and try and pick up as much as I can then later in the year I'll start a 'Project Specific' thread.

In the meantime what next here?

Dave

mackrackit
- 13th July 2010, 16:12
Would be go if I could. Like I said when I first joined the Forum: I may not be that brightest but I am a trier:)
Same here, I just add more voltage though...:p


In the meantime what next here?

While you are getting the RF modules figured out you could start on the project using wires.
Then all you will have to do is add the RF stuff later on.

LEDave
- 13th July 2010, 16:22
While you are getting the RF modules figured out you could start on the project using wires.Then all you will have to do is add the RF stuff later on.

Good shout, I like it and I'm on it Boss:)

I'm thinking two 16F684's SEROUT from one into SERIN on the other to LCD / or Communicator. With a push_button on SEROUT PIC to simulate the beam at this stage with an LDR / potential divider to trigger the 'SEND DATA' at night fall.

How does that sound?

Dave

mackrackit
- 13th July 2010, 16:45
SEROUT is very limited.

Use SEROUT2/SERIN2 .
Then when you get a PIC with hardware serial the syntax will be the same.

LEDave
- 13th July 2010, 16:57
Use SEROUT2/SERIN2 . Then when you get a PIC with hardware serial the syntax will be the same.

SERIN / OUT2 it is. Cheers mackrackit.

I nearly missed that one:)
Same here, I just add more voltage though...

Dave

LEDave
- 14th July 2010, 23:21
I've been GQQGLING around looking for rfpic info and on several sites I've found articles from people all saying that the rfpic battery had gone flat after only about a week.Has anyone here found this to be the case?

I guess for the project the rfpic will need to be in sleep mode as much as possible to save the battery power.

Dave

LEDave
- 25th July 2010, 19:10
Quick question:

When does an INPUT voltage level on a pin become an INPUT? What I'm clumsily trying to say is that when I use my potential divider (fixed resistor and an LDR) the voltage level will gradually rise until the PIC reads that voltage as a logic 1, will that be exactly five volts or less?

Dave

mackrackit
- 25th July 2010, 19:26
If you are still using the 684 take a look at table 15.5 in the data sheet.
There are two types of inputs, schmit and TTL. One is 0.8 and the other is 2.

How is everything going with the project?

LEDave
- 25th July 2010, 20:02
Hi mackrackit,


If you are still using the 684 take a look at table 15.5 in the data sheet.
There are two types of inputs, schmit and TTL. One is 0.8 and the other is 2.

Yes still on the 684, I'll have a read of the data sheet tonight.

The Project is coming along, I love these PIC's and what they can do (still frustrated at what I can't do mind:() When you start a project it's amazing where things lead and what has to be taken into account, example:

The parent birds fly into the box bringing in food and each time they do so they break the beam and a counter (divide by two as we said earlier) gets incremented. Then as night falls the voltage level on the P0T_Divider rises and when it's dark a pin reads voltage 1 and that days data gets rfpic'ed across. However simple little things to consider, how dark is dark? Is a passing cloud 'dark' enough to make the data be sent prematurely etc...? Things like that.

I've been spending time analysing Bruce's rfpic program to try and figure out just what is going on and how it all works. Plus I've been dabbling with some basic assembler...oh dear:eek:

It's a good job I've got until next Spring to get this up and running:) Also learning to program is a great thing to go over the Winter Months too.

So, slow progress, still loving it.

Dave

LEDave
- 27th July 2010, 15:12
I'm probably way of beam here but when I read the data sheet for the 684 and then read about the 'Schmitt Trigger' it seemed to me that this worked on a pre defined voltage level (the voltage can vary up to the set value). Maybe this could be the way to ensure that any data sent only gets sent at a 'set' light / voltage level.

Am I reading this right?

I know I could also just use the potential divider set to a voltage / light level and even add in a time delay routine (say an hour) to make sure the data only gets sent once and when it is dark.

Interesting though.

Dave

mackrackit
- 28th July 2010, 00:11
I hope this makes sense..

At around 5 vdd.

A TTL input pin will go "HIGH" around 1.1 volts. 1.1 volts is the ON?OFF threshold.

A Schmitt input will go "HIGH" around 3 volts but stay high until it drops below 1.6 or so.

Your meter may vary a bit. Mine does :)

Personally in an application I will not call an input high before 3.6 volts and LOW has to be 1.5 or less. This is dealing with limit switches and such. Basically I figure it is either on or off, Dirty contacts, bouncy switches and such adds to the problem.

If I need to split hairs (volts) I do not like to rely on TTL or ST for the threshold. I set up an ADC.

LEDave
- 28th July 2010, 11:08
Interesting,


If I need to split hairs (volts) I do not like to rely on TTL or ST for the threshold. I set up an ADC.

Well I've never done ADC, it does look an ideal application for the project and new learning for me.

When you have some spare time (spare time, as rare as hen's teeth he says) could we do some ADC stuff? No rush, as and when, as ever.

Dave

mackrackit
- 28th July 2010, 11:27
When you have some spare time (spare time, as rare as hen's teeth he says) could we do some ADC stuff?
Sure, I have been planning to write some some basic ADC stuff for the wiki so I will use the 684 as one of the example chips.

But in the mean time you can not beat this foe an explanation. Different chip but most still applies.
http://rentron.com/PIC12C67XAD.htm

LEDave
- 28th July 2010, 12:20
Sure, I have been planning to write some some basic ADC stuff for the wiki so I will use the 684 as one of the example chips.

Brilliant:)

I've had a quick look at the link, looks very good. I'll have a read / study this evening and try and get a grasp of what's going on.

Thanks for that mackrackit.

Dave

mackrackit
- 29th July 2010, 23:04
I am feeling lazy so I will do an article later. For now here is some stuff to play with. I found that I am out of 684s so I did this with a 676. Should work with the 684.

For now we will look at 8 bit ADC. Using 8 bit the signal is divided into 256 steps, 0 - 255.
The ADC will return 0 - 255. If you use this to read a voltage and you are using 5 volts for the VDD/reference, 1 volt will return 51, 2 volts will return 102, 3 volts.....

You will not find this way of doing the ADC in the manual, but if you follow along with the data sheet you will see what is happening with the registers.

I wrote the examples for the PicKit1 test board. Using the on-board POT and LEDs.
Example #1


'FL PIC16F676
'16F676 ADC ON PICKIT_1
DEFINE OSC 4
@ __config _INTRC_OSC_NOCLKOUT &amp; _WDT_ON &amp; _MCLRE_OFF &amp; _CP_OFF
ANSEL = %00000001 'CHANNEL AN0
ADCON1 = %00010000 'FOSC/8
TRISA = %00000001
CMCON = %00000111
CHAN0 VAR BYTE 'VAR TO HOLD ADC0 READING

CHECK:
GOSUB ADC_0
IF CHAN0 > 128 THEN
GOSUB BLINK
ELSE
PORTA = %00000000
ENDIF
GOTO CHECK

BLINK:
D0_HIGH:
TRISA = %11001111
PORTA = %00010000
PAUSE 500
D1_HIGH:
TRISA = %11001111
PORTA = %00100000
PAUSE 500
D2_HIGH:
TRISA = %11101011
PORTA = %00010000
PAUSE 500
D3_HIGH:
TRISA = %11101011
PORTA = %00000100
PAUSE 500
RETURN

ADC_0: 'READ AN0
ADCON0 = %00000001 'TURNS ADC ON, SET FOR 8 BIT
GOSUB READ_AD
CHAN0 = ADRESH
RETURN

READ_AD: 'DOES THE ADC CONVERSION
PAUSE 50
ADCON0.1=1
WHILE ADCON0.1=1:WEND
RETURN







Example #2

'FL PIC16F676
'16F676 ADC ON PICKIT_1 WITH CASE SELECT
DEFINE OSC 4
@ __config _INTRC_OSC_NOCLKOUT &amp; _WDT_ON &amp; _MCLRE_OFF &amp; _CP_OFF
ANSEL = %00000001 'CHANNEL AN0
ADCON1 = %00010000 'FOSC/8
TRISA = %00000001
CMCON = %00000111
CHAN0 VAR BYTE 'VAR TO HOLD ADC0 READING

CHECK:
GOSUB ADC_0
GOSUB BLINK
GOTO CHECK

BLINK:
SELECT CASE CHAN0
CASE IS > 254
TRISA = %11001111
PORTA = %00010000
CASE IS > 192
TRISA = %11001111
PORTA = %00100000
CASE IS > 128
TRISA = %11101011
PORTA = %00010000
CASE IS > 64
TRISA = %11101011
PORTA = %00000100
CASE ELSE
PORTA = %00000000
END SELECT
RETURN

ADC_0: 'READ AN0
ADCON0 = %00000001 'TURNS ADC ON, SET FOR 8 BIT
GOSUB READ_AD
CHAN0 = ADRESH
RETURN

READ_AD: 'DOES THE ADC CONVERSION
PAUSE 50
ADCON0.1=1
WHILE ADCON0.1=1:WEND
RETURN

LEDave
- 29th July 2010, 23:59
Hi mackrackit,

Thanks for your post and program.

Right then. I need to print off your program and the relevant parts of the 684 data sheet and work it through.

Very interesting stuff this, let me see how far I can get and see how much I can figure out before I ask my first question.

Dave

mackrackit
- 1st August 2010, 09:13
Hey Dave,
Did my code work on your PicKit1 board?
I did find a couple 684s in the bottom of a drawer. Once the pins were straightned out they worked in the test board. But I had to program them with a PicKit2 The PicKit1 kept giving an error?

LEDave
- 1st August 2010, 19:18
Hi mackrackit,

Sorry for the late reply, Sunday is 'family' day:):confused::eek:(say no more!).


Did my code work on your PicKit1 board?
I did find a couple 684s in the bottom of a drawer. Once the pins were straightned out they worked in the test board. But I had to program them with a PicKit2 The PicKit1 kept giving an error?

I had some errors on Compiling the first program, so had a hunt around looking for Configuration_Fuse info (found this page:http://www.picbasic.co.uk/forum/showthread.php?t=543)

So changed your code to this for the 684:


DEFINE OSC 4

CMCON0 - from CMON

@DEVICE_INTRC_OSC_NOCLKOUT
@DEVICE_WDT_ON
@DEVICE_MCLRE_OFF
@DEVICE_CP_OFF

The program compiled and ran a treat. What happens is that when a Voltage of 2.5V appears on PORTA.0 (pin13 on the 684) the LED's on D0-D3 light in turn on after the other. If the Voltage drops below 2.5V they turn off. How does that sound.

Dave

mackrackit
- 1st August 2010, 19:36
Yup, family come first!!!

I use MPASM in place of PM for the assembler. If you are using Micro Code Studio you can change that in compiler options. PM is OK though, until you get to using 18F parts.

Yes, on the first code the analog break point is at the halfway point.
When you get a chance to run the second code you will see how it is split even more. Lots of things can be done with this, like the code shows, one input can effectively become many, sort of.

Now take all this back to the LDR thing and you can have light, dark, and options for something in between.

LEDave
- 1st August 2010, 19:46
For the second program I made the same Config changes, the program worked a treat two:

When the pot is turned LED D3 lights at approx:1.25V (pin13), D2 lights at 2.5V (D3 goes out). At 3.75V D1 lights (D2 goes out). And at 4.95V D0 lights up and D1 goes out.

I must say mackrackit, this is very clever stuff.

I'm thinking for the project, the LDR set against a pre-defined ADC voltage trigger level would be spot on to send the data at a set light night time light level.

I'm still doing loads of reading / studying, I've got a few things I'm not sure of so may have to get back to you on those, bear with me.

Dave

LEDave
- 1st August 2010, 19:54
Ah, I see you posted while I was still composing.....:)


Now take all this back to the LDR thing and you can have light, dark, and options for something in between.

Yes this would work a dream.

I think this project will contain nearly everything we've covered so far in one program:eek: RF.ADC,SEROUT2,EEPROM data storage, Serial Communicator - LCD......!

Loving it: Dave

mackrackit
- 1st August 2010, 20:11
I'm still doing loads of reading / studying, I've got a few things I'm not sure of so may have to get back to you on those, bear with me.
No problem. If only all students worked as hard as you have...


I think this project will contain nearly everything we've covered so far in one program RF.ADC,SEROUT2,EEPROM data storage, Serial Communicator - LCD......!
And all since February... COOL!!!!

LEDave
- 1st August 2010, 22:13
No problem. If only all students worked as hard as you have...

Like I said way back when mackrackit, I'm not naturally bright but I am a trier....:)


And all since February... COOL!!!!

Yes it's amazing really. As we all know I couldn't blink an LED when I first came here...! As much to do with the Teacher as the pupil me thinks / knows...!

Dave

mackrackit
- 2nd August 2010, 21:04
Hey Dave..

What happens if the order of CASE IS is switched around? Why? ;)

SELECT CASE CHAN0
CASE IS > 254
TRISA = %11001111
PORTA = %00010000
CASE IS > 192
TRISA = %11001111
PORTA = %00100000
CASE IS > 128
TRISA = %11101011
PORTA = %00010000
CASE IS > 64
TRISA = %11101011
PORTA = %00000100
CASE ELSE
PORTA = %00000000
END SELECT

LEDave
- 3rd August 2010, 01:30
Hi mackrackit,

I changed the program SELECT CASE to this:


SELECT CASE CHAN0
CASE IS > 192
TRISA = %11001111
PORTA = %00100000
CASE IS > 254
TRISA = %11001111
PORTA = %00010000
CASE IS > 128
TRISA = %11101011
PORTA = %00010000
CASE IS > 64
TRISA = %11101011
PORTA = %00000100
CASE ELSE
PORTA = %00000000
END SELECT

With this D0 didn't light, D1 lit at 5V, D2 at 3.65V, D3 at 2.45V. Mmm.

So your question was:
What happens if the order of CASE IS is switched around? Why?;)

My answer is: I don't know for sure:o But, is it because for an 8bit ADC the conversion started at 192 (not 255 2_to_the_power_eight) therefore 192 became 5V. 255 would then be greater than the 5V supply reference voltage so wouldn't be read and was missed out. The other readings were all lower so were all calculated and there LED's lit.

I'm suspecting I'm North of the North pole.......Again :(

Dave

mackrackit
- 3rd August 2010, 02:41
I'm suspecting I'm North of the North pole
Then you are heading South.... Maybe.

The ADC creates a moving target. Try hard coding the value for "CHAN0".
Then.
Try reversing the values from the original but use < with the ADC active.

LEDave
- 3rd August 2010, 17:57
Hi mackrackit,

I could be going North again..........:(


Try hard coding the value for "CHAN0".

From your second example:


CHAN0 = ADRESH

To my understanding ADRESH_high_byte contains the value of the ADC conversion, so to hard code the value for CHAN0 it would simply be: CHAN0=%10101010 as an example, is this right?

I think I'm confusing myself here (correction I am confusing myself here...lol) But from your examples if we're doing an 8 bit ADC I thought we would be using ADRESL_low_byte and ADRESH&L for a 10 bit conversion (8+2) or does using ADRESH make the conversion more accurate?

Dave

mackrackit
- 3rd August 2010, 18:20
CHAN0 = 193
Would also work.

Take a look at this from the data sheet.
4657
When using 8 bit ADC we are after the MSB from ADRESH.
If we want 10 bit ADC we would grab a couple extra bits from ADRESL.

So you are on the right track. ;)
Here is a snippet from something doing 10 bit.
TC is a WORD size VAR

getT2:
ADCON0= %00000101 '$5 '%00000101 AN1
ADCON2.7 = 1
gosub getAD
TC.highbyte = ADRESH
TC.lowbyte = ADRESL
return

getAD:
pause 50
WHILE ADCON0.1=1:WEND
return

LEDave
- 3rd August 2010, 18:41
When using 8 bit ADC we are after the MSB from ADRESH.
If we want 10 bit ADC we would grab a couple extra bits from ADRESL.

Ok..... Heading South again (albeit walking backwards...:eek:)


Then.Try reversing the values from the original but use < with the ADC active.

I'll do this when I get back in later tonight (I'm off keyboard playing).......ah.

Dave

LEDave
- 4th August 2010, 00:37
Hi mackrackit,


Try hard coding the value for "CHAN0".

With CHAN0 = ADRESH all LED's lit in sequence.
With CHAN0 = 255 D0 lits.
With CHAN0 = 193 D1 lits.
with CHAN0 = 129 D2 lits.
with CHAN0 = 65 D3 lits.

So using greater than> the sequence still followed!


Try reversing the values from the original but use < with the ADC active.

Then using <than and ADRESH D0 lit.
With CHAN0 = 253 D0 lit.
With CHAN0 = 191 D0 lit.
With CHAN0 = 127 D0 lit.
With CHAN0 = 63 D0 lit.

So using less <than only D0 lit! across all settings. I wasn't expecting that I must admit, I thought it would work the same as > only in reverse.

mackrackit,is the reason only led0 lights because the ADC isn't using the MSB's when doing the conversion, or something like that. Or have I simply made a mistake here.

Dave

mackrackit
- 4th August 2010, 11:44
Think of SELECT CASE as a series of IF/THENS.
The first time a condition is met the code jumps to END SELECT.

If a "random" value is being tested IF/THEN is probably the better option.
In the example we have been working with when the value is predictable SELECT CASE is nice.
But that also means the order that SELECT CASE uses matches the "predictable" value.

Give this a shot

SELECT CASE CHAN0
CASE IS < 64
TRISA = %11001111 'D0
PORTA = %00010000
CASE IS < 128
TRISA = %11001111 'D1
PORTA = %00100000
CASE IS < 192
TRISA = %11101011 'D2
PORTA = %00010000
CASE IS < 254
TRISA = %11101011 'D3
PORTA = %00000100
CASE ELSE
PORTA = %00000000
END SELECT
BTW. I will have limited to none internet till Monday so I may not be around here much in the mean time.

Have fun!!!

LEDave
- 4th August 2010, 13:54
Give this a shot

Yep, spot on.


BTW. I will have limited to none internet till Monday so I may not be around here much in the mean time.

Ok. Watch out for IWS though (Internet_withdrawl_Syndrom).It starts after about three hours with me, symptoms:Anxiety(have I any emails?)...This news paper isn't in PDF format(worse still it's non tech related)....etc. If left untreated this is a serious condition, only known cures:WIFI mobile phone or a broadband connection, so check you route!


Have fun!!!

You too, plenty of reading for me on ADC over the next few days.

Dave

LEDave
- 10th August 2010, 20:25
I bet you thought I'd left the Country the time this one has taken me. I must admit I really confused myself at times and went around in circles a little (ok, a lot).

Anyway I think I've managed to convert mackrackit's 8bit ADC to a 10bit for the 16F684. I would be very interested to hear how I've done on this one. Seems to work, or have I just 'lucked in'?


DEFINE OSC 4

@DEVICE_INTRC_OSC_NOCLKOUT
@DEVICE_WDT_ON
@DEVICE_MCLRE_OFF
@DEVICE_CP_OFF

ANSEL = %00000001 'CHANNEL AN0
ADCON1 = %01010000 'FOSC/16
TRISA = %00000001 'AN0_Input Pin
CMCON0 = %00000111 'COMPARATORS OFF.
CHAN0 VAR word 'VAR TO HOLD ADC0N READING (10-BIT)

CHECK:
GOSUB ADC_0
GOSUB BLINK
GOTO CHECK

BLINK:
SELECT CASE CHAN0

CASE IS > 64
TRISA = %11001111
PORTA = %00010000
CASE ELSE
PORTA = %00000000
END SELECT
RETURN

ADC_0: 'READ AN0
ADCON0 = %10000001 'BIT0=ADC ENABLE: BIT1=A/D CONVERSION STATUS BIT
'BITS2-4=AN0 CHANNEL SELECT BIT(CHS0): ADFM BIT1= right justified
GOSUB READ_AD
CHAN0.highbyte = ADRESH 'A/D HIGHBYTE
CHAN0.LOWBYTE = ADRESL 'A/D LOWBYTE
RETURN

READ_AD: 'START THE ADC CONVERSION
PAUSE 50
ADCON0.1=1 '1 = A/D conversion cycle in progress.
'Setting this bit starts an A/D conversion cycle.
WHILE ADCON0.1=1:WEND 'Do WHILE condition is TRUE (I like WEND!).
RETURN



Dave

mackrackit
- 11th August 2010, 03:34
(I like WEND!) :D

Looks like you got it!!!

Now change the select case to use the ten bit values. 0 to 1023.
And for you project you may want to play with some averaging. Analog will tend to drift with a temperature flux (resistors) or more so for your application how sensitive you want the LDR (stray car lights?).

LEDave
- 11th August 2010, 10:54
I changed the value to 1022 and the led lit and occasionally flicked off then back on, so right at the end of the 10bit conversion / pot sensitivity. At a value of 1 the led lit with some pot 'travel' still left. So pretty spot on I'd say::)


And for you project you may want to play with some averaging. Analog will tend to drift with a temperature flux (resistors) or more so for your application how sensitive you want the LDR (stray car lights?).

Mmm, interesting. I want to transmit the data (days total count) when it's dark and the parents have stopped feeding the young for the day. Like you say though, I don't want say the garden PIR light (when the Badger arrives) to effect things so some averaging and tweaking / testing needed here.

As ever a big thank you for the 8bit ADC program pointer mackrackit. When it came to doing the 10bit conversion I've learned a lot about setting REGISTER bits, I'm still painfully slow but I guess that will improve with time / practise really interesting learning though.


ADFM BIT1= right justified

Just spotted that this should read ADFM BIT7=1= right justified

And as for WEND, I suppose elegant would be the word.

Dave

mackrackit
- 11th August 2010, 11:56
Just spotted that this should read ADFM BIT7=1= right justified
But your code was correct.... ;)

Have you done a FOR/NEXT loop yet?
Here is a snip from an 8 bit averaging. Pretty simple. Some like to throw out the first and last readings and only use the middle values. I guess it depends on the app..

GET_T:
ADC_TEMP = 0
FOR X_TEMP = 1 TO 20
ADCON0=00000001
GOSUB READ_AD
S_TEMP = ADRESH
ADC_TEMP = ADC_TEMP + S_TEMP
PAUSE 250
NEXT X_TEMP
OUT_TEMP = ADC_TEMP / 20

mackrackit
- 11th August 2010, 12:22
Here is another way.
http://www.picbasic.co.uk/forum/content.php?r=208-Averaging-fast-moving-readings

LEDave
- 11th August 2010, 13:14
Have you done a FOR/NEXT loop yet?

Yes, your good self and Henrik explained FOR/NEXT loop and LOOKUP when I was using a BCD driver to make a seven segment display count up and down from 0-9 and write my name. Seems like ages ago now, it was only February/March this year:eek:

So your example adds the value S_TEMP to the stored value ADC_TEMP which is done 20 times, then the ADC_TEMP value is output as OUT_TEMP a 20 cycle average (I hope I've read this right).

Now I'm thinking thermocouple / ADC / Seven segment display.....Another project!

Ah, before I forget, from your ADC/rentron explanation link you posted earlier. The ADC conversion is displayed on a rather nice data logger display, is this logger included in the Microcode studio package the same as the Serial Communicator? Image below:

Dave

LEDave
- 11th August 2010, 13:33
Here is another way.

It's not fair you know, Derrel Taylor may have the same initials as me, even the same surname but his brain must be at least twice the size........at least!:(

Very clever program (I'll fess up I had to WIKI hysteresis(I had heard of it though)).

Dave

mackrackit
- 11th August 2010, 13:50
I sometimes think DT is part machine :) The stuff he comes up with is invaluable around here. I am just happy that he shares his hard earned knowledge.

The GUI from Bruce's site I think is written in Visual Basic. Here is something he has to offer.
http://www.rentron.com/AD_LOG.htm

Do you have a language for the PC that you use? You could make you own.

LEDave
- 11th August 2010, 15:16
I sometimes think DT is part machine :) The stuff he comes up with is invaluable around here. I am just happy that he shares his hard earned knowledge.


The same as that. Anyone who gives of their time / knowledge gets my appreciation. Maybe one day I'll be able to help someone out, hey maybe other 'lurker newbies' have been indireclty helped by the Q's I've asked, even the answers I given.


The GUI from Bruce's site I think is written in Visual Basic. Here is something he has to offer.
http://www.rentron.com/AD_LOG.htm

Thanks for that mackrackit.


Do you have a language for the PC that you use? You could make you own.

Well I do swear at it from time to time;) I don't think I'm clever enough to make my own data_logger application though. Interestingly, when I was researching rfpic's, several times I came across Visual Basic being used in applications to store transmitted_data. For this project
when the daily count is transmitted from rfpic - pic - to serial communicator it will need to be stored somewhere, so maybe a visual basic application could be the answer.

I have got Microsoft VB 2008 Express Edition on my pc, also Visual C++

Dave

mackrackit
- 11th August 2010, 16:35
hey maybe other 'lurker newbies' have been indireclty helped by the Q's I've asked, even the answers I given.
I would imagine they have been..

VB 2008.. I hear it is not to bad. Does it have comms built in?

LEDave
- 11th August 2010, 17:03
Does it have comms built in?

I don't know:o

I did find these headings though:


How to: Show Available Serial Ports in Visual Basic
Demonstrates how to show available serial ports.

How to: Dial Modems Attached to Serial Ports in Visual Basic
Demonstrates how to dial a modem attached to the serial port of a computer.

How to: Send Strings to Serial Ports in Visual Basic
Demonstrates how to send a string to a computer's serial port.

How to: Receive Strings From Serial Ports in Visual Basic
Demonstrates how to receive a string from a computer's serial port.

mackrackit
- 11th August 2010, 17:10
If all of that is from VB08 then I would say you have what you need.
Sounds like you will be writing a test terminal soon ;)

LEDave
- 11th August 2010, 17:25
Sounds like you will be writing a test terminal soon

Mmm.

How about:

Something like this maybe (a VB example)......?


Function ReceiveSerialData() As String
' Receive strings from a serial port.
Dim returnStr As String = ""

Using com1 As IO.Ports.SerialPort = _
My.Computer.Ports.OpenSerialPort("COM1")
Do
Dim Incoming As String = com1.ReadLine()
If Incoming Is Nothing Then
Exit Do
Else
returnStr &= Incoming & vbCrLf
End If
Loop
End Using

Return returnStr
End Function

mackrackit
- 11th August 2010, 17:35
VB 5 was the "in thing" the last time I used it. :p
So...
Does it work?

LEDave
- 11th August 2010, 17:56
So... Does it work?

I don't know. I'm not even sure what application to use, is it a:

1/ Windows Form Application

2/ Class Library

3/ WPF Application

4/ WPF Browser Application

5/ Console Application

I know less about VB than I do PIC_Basic.........(a lot less):(

Also the serial port is on a turn of the Century Compaq pc so I'd have to transfer the application over I guess.

Dave

mackrackit
- 11th August 2010, 18:35
My guess would be
1/ Windows Form Application

Have you ever tried a serial to USB converter?

PC code... Being that you do not mind a learning curve and not all that familiar with VB, you could start learning Python or something like that. In my opinion there is something to be said about cross platform comparability. Linux, MAC OS, Windows, in the back ground on a server, Droids, broken iPhones...

LEDave
- 11th August 2010, 19:47
Being that you do not mind a learning curve and not all that familiar with VB, you could start learning.......

I was just thinking the same thing over tea. It would be really neat to have a complete project that gathers the data, rfpic's it over then stores it in an application / program.

So PYTHON v's VB how similar or which is best / more suited?


Is this the sort of thing, serial to USB?

http://www.amazon.co.uk/USB-RS232-Converter-Cable/dp/B00077DJIQ

Darrel Taylor
- 11th August 2010, 19:52
Here's some good info on VB over at rentron.
http://www.rentron.com/VisualBasic.htm

Check out the Receiving Data From A Microcontroller and Sending Data To A Microcontroller sections. (but read the others too)


And no, I'm not a machine ...
By definition, a machine does "work (http://en.wikipedia.org/wiki/Machine)".
I'm too busy playing for that. :)

LEDave
- 11th August 2010, 20:11
Check out the Receiving Data From A Microcontroller and Sending Data To A Microcontroller sections.

Will do Darrel, thanks for the info / pointer.

Me thinks I suddenly have a little bit of learning to do:eek:

Dave

mackrackit
- 11th August 2010, 20:15
And no, I'm not a machine ...
By definition, a machine does "work".
I'm too busy playing for that.
Well I 'ment that in a good way. :D

Yup, that is the cable.


So PYTHON v's VB how similar or which is best / more suited?
That is a loaded question. Could start a heated debate...

Not similar at all. There are a few GUI builders for Python but the strange thing is, not all of the GUIs are cross platform. Tk comes with the typical python install, cross platform, but some say it is not the prettiest.

The guy that invented python was/is a C programmer so python looks more like C at first glance.

More suited... ???
VB is pretty much locked to windows, we know that..., but if that does not bother you..
In the end I will say it depends on the person at the keyboard. They will both make reliable code.

I will bet you could have something up and running faster with VB. The link Darrel gave should really speed things up.

LEDave
- 11th August 2010, 20:35
I will say it depends on the person at the keyboard.

That'll be me then.......worryingly;)


I will bet you could have something up and running faster with VB.

I'll go with VB for the project then.


The link Darrel gave should really speed things up

I think it's only fair to mention that when I look at VB code, I have the same / less understanding than when I lit my first PICBASIC led. That's not to say I won't give it my best shot though.

I'll order up a cable.

Dave

LEDave
- 11th August 2010, 23:28
I've just re-read:


Receiving Data From A Microcontroller

Clever or what!

I'm off to bed now to think about what I don't know:(

&

And dream about what I might know fairly soon:)

Dave

LEDave
- 12th August 2010, 11:25
I've ordered the USB-RS cable up.

Not sure how to go about learning VB, so I was thinking of going through the RENTRON rec/send programs line by line and taking notes.

Dave

mackrackit
- 12th August 2010, 12:03
Make an app with a "button" that when clicked writes "hello world" in a text box.
Then you can move to displaying the serial input in the same Tbox.

And of course read everything Bruce has to offer....

LEDave
- 12th August 2010, 18:21
I've now got an App with a text box and a button:)

All I need now is to figure out how to display 'Hello World' when the button is pressed:eek:

This is going to take a while as I've loads of reading to do, so please bear with me. If I get really stuck then I'll have to ask.

Have a nice Weekend everybody.

VB_Dave

mackrackit
- 12th August 2010, 20:19
All I need now is to figure out how to display 'Hello World' when the button is pressed
And in color... ;)

LEDave
- 12th August 2010, 21:13
A small breakthrough: "Hello World" when the button is pressed.......:


Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = "Hello World"

End Sub
End Class

I just read this: And in color... ! I'm more of a Henry Ford man myself, color it is then.....!

Dave

mackrackit
- 12th August 2010, 21:22
RED Mustangs ??? The new Ford :p

Might be cool to have numbers and letters a different color..... If you are making your own terminal thing may as well trick it out...

LEDave
- 12th August 2010, 23:30
This is my 'attemp' to write the 'H' 'e' of Hello world in different colors in the text box.The 'Button' in the Form when pressed outputs the text 'He'.

Is this remotely close or am I heading North......again:(


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


Dim First As String
Dim second As String
Dim Third As String
Dim value As Color

value = Color.Red

First = "H"

value = Color.Blue

second = "e"

Third = First & second

TextBox1.Text = Third

End Sub
End Class


I think I needed to add somehow/somewhere to get the colors to work/change:


Public Shared ReadOnly Property Red As Color


My brother_in_law used to have a Mustang (V8) I was about 14 when he had it. I'm not sure if I liked the looks or the sound the best:)

Dave

mackrackit
- 13th August 2010, 06:04
Like I said, been a long time since I used VB..

I think you will need to parse the string into an array maybe and then check the elements, I will not even try the syntax. But this might give some clues.
http://www.vb6.us/tutorials/vb-string-array-functions-split-join-filter

LEDave
- 13th August 2010, 15:05
Hi mackrackit,


I think you will need to parse the string into an array maybe and then check the elements

I've heard of all three and never used any of them, so more reading for me tonight.

I suppose an array is an array, if I learn about them for VB the same theory applies to a picbasic array so all part of the learning curve, the same for parse and elements.

Dave

mackrackit
- 13th August 2010, 16:41
I would not get hung up on the color thing right now, but of course it is up to you.
Getting the data from the MCU to VB is the important part. Dressing it up can come later.

LEDave
- 13th August 2010, 22:21
Hi mackrackit,


Getting the data from the MCU to VB is the important part. Dressing it up can come later.

Indeed, Ill stick with that for now.

As as aside:

Learning to program is similar to learning to play a keyboard in that you want to be able to jump in and create/play something just like the original, however there's a big learning curve to be overcome and there are no short cuts! Wonderful feeling when things start to happen though.

Dave

LEDave
- 17th August 2010, 18:28
I'm still going through the VB stuff and waiting for the usb lead to arrive in between a busy schedule.........:eek:

Dave

mackrackit
- 17th August 2010, 19:48
Did you see this?
http://www.picbasic.co.uk/forum/showthread.php?t=13609
Post #9 and #10.

LEDave
- 17th August 2010, 22:44
Cheers mackrackit,

That's one serious and impressive interface. I think the thing that really impresses me the most here is the way you guys 'see' the solution in software if that makes sense, very,very impressive.

I'm going to have to play catch up and try and fill some very large gaps in my knowledge base (if I can).

Here's trying.

Dave

LEDave
- 18th August 2010, 22:07
I've been installing the software for the USB-serial cable and a warning has come up saying basically that the software hasn't passed Windows logo testing and may destabalize or impair system performance now or in the future.......:eek:

Should I ignore and install or head the warning? I've made a system restore point before I started the install.

Or is there another driver that would do the job?

Dave

mackrackit
- 18th August 2010, 22:19
I saw this on the amazon link you gave

Bought this cable, and the little CD that came with it clearly assumed a greater level of knowledge than I possessed! I was lost and couldn't install a driver for it. Then I found the link to the seller (Aquarius Computers) and an invitation to contact via a contact form. This was 2.30pm on a Saturday, and by 4pm same day I had a reply pointing me at a site to directly download the driver, which was straightforward to install. Everything working smoothly now.
If you have the same problem (I have XP and using the cable to run an external modem) Google "PL-2303 Software and Drivers" (include the double quotes) and choose the link ending ID=31. There, on the Prolific Technology Inc. site, you will find a file to download called wd_pl2303_v20019v2028.zip. Caters for Win98SE/ME and Win2K/XP/2003.

LEDave
- 18th August 2010, 22:32
Hi mackrackit,

On the disc there's a folder called: PL2303 which contains a winxp folder containing: PL2303-DRIVER-INSTALLER.

Is that the one I need / should install?

Dave

mackrackit
- 18th August 2010, 22:39
I would get the latest greatest from the manufacture.

What OS are you running?

LEDave
- 18th August 2010, 22:47
What OS are you running?

XP.

Shall I go for:


Google "PL-2303 Software and Drivers"?

This one:


PL-2303 USB to Serial Bridge (H, HX, X) Installshield Driver Setup Program
Installer version & Build date: 1.3.0 (2010-7-15)
Windows 98/ME Driver: v2.0.0.19
Windows 2000/XP/Server2003 (32 & 64-bit) WDM WHQL Driver: v2.0.13.130
Windows Vista/7/Server2008 (32 & 64-bit) WDF WHQL Driver: v3.3.11.152
Language Support: English (default), Chinese (Traditional), Chinese (Simplified), Japanese
For Prolific USB VID_067B&PID_2303 Only

Dave

mackrackit
- 18th August 2010, 23:27
That looks good.
You did say a fresh restore point has been made. Are you backed-up? :rolleyes:

LEDave
- 19th August 2010, 00:10
Are you backed-up?

10 days ago, I could do a new one in the morning. I do a complete disc image, it's worth it.

Dave

LEDave
- 19th August 2010, 17:02
Mmm,

Well I installed the driver:
Prolific USB-Serial Com Port (COM3)

However it says:
This device cannot start. (Code 10)

And code 10 from M-SOFT says:


Code 10

If the device has a FailReasonString value in its hardware key, that string is displayed as the error message. The driver or enumerator puts this registry string value there. If there is no FailReasonString in the hardware key, you receive the following error message:
This device cannot start. (Code 10)
Recommended resolutions

Here are some things that you can try to resolve this problem.

Update the driver

In the device Properties dialog box, click the Driver tab, and then click Update Driver to start the Hardware Update Wizard. Follow the instructions to update the driver.

You may be prompted to provide the path of the driver. Windows may have the driver built-in, or may still have the driver files installed from the last time that you set up the device. If you are asked for the driver and you do not have it, you can try to download the latest driver from the hardware vendor’s Web site.

I've deleted and re-installed it, same outcome and checked for a later driver, same outcome.

What's meant to happen here then mackrackit, is the USB-Serial meant to work through the Serial Communicator or via it's own application?

Dave

mackrackit
- 19th August 2010, 17:21
Once it is installed it will look just like a regular serial port to your PC. You will be able to use serial communicator, hyper-terminal or whatever else you have.

Device manager shows it as COM3?

When in Device Manager and trying to update the driver from there, do you get any errors?
Like maybe the software does not support the device?

LEDave
- 19th August 2010, 18:44
When in Device Manager and trying to update the driver from there, do you get any errors? Like maybe the software does not support the device?

No it (Windows) says couldn't find a better match.

It definately says PORTCOM3

mackrackit
- 19th August 2010, 19:05
If manually pointing to the driver and restarting the machine does not make it work I would say you got the Amazon/Ebay scam :mad:

http://www.prolific.com.tw/eng/FAQs.asp?ID=50

LEDave
- 19th August 2010, 19:55
Looks like it doesn't it...........Looks like I've been fleeced!:(

Back to the drawing board....!

Are there any other drivers out there we know of (he typed hopefully)?

Dave

LEDave
- 19th August 2010, 21:27
I was searching the net for a RS343 - USB driver and came across this freeware datalogger, looks interesting:
http://download.cnet.com/RS232-Data-Logger/3000-2094_4-10497745.html?tag=mncol

Also for any newbies who followed the ADC mackrackit worked through recenlty, here's an interesting article I came across at Microchip, hope it helps:

mackrackit
- 20th August 2010, 08:23
Are there any other drivers out there we know of (he typed hopefully)?
Difficult to fix bad hardware with software.

A little more money than the one you have but I have three of these and so far so good.
http://www.tripplite.com/en/products/model.cfm?txtModelID=2430

LEDave
- 20th August 2010, 16:08
Hi mackrackit,

I thought I'd give the cable 'one more go' and would you believe it the cable 'connected' to the PIC. It wouldn't send/receive at first though, so changed the settings to:


COM1 :BAUD 2400 :No Parity :Byte size is 8 :1 stop bit

And seems to be working now:D

Do those settings seem ok to you?

How lucky was that! I very nearly called it a day with that cable/driver.

Dave

mackrackit
- 20th August 2010, 16:17
COOL!!!!

Yup, those settings are fine.
As long as they match the PIC. :)

LEDave
- 20th August 2010, 16:35
Well the PIC is 2400 inverted.

That really was the last throw of the dice regards the driver/cable, thought I'd lucked out there.

So now I can use the serial communicator on my DELL without having to wear headphones when the old COMPAQ fires up (it sounds like a hair dryer.....:)

Dave

LEDave
- 20th August 2010, 23:18
I'm still working through the VB stuff, lots to learn still and slow progress being made. I'm thinking I'll post VB questions on the VB-PIC thread that was linked here the other day.

Dave

LEDave
- 24th August 2010, 00:31
Hi mackrackit,

I've decided that there are two elements to the project the I need to target my learning on:

1/ The rfpic tx/rx - I guess breaking down, learning and modifying Bruce's programs in a nutshell.

2/ VB and transferring the rx data from the PIC into a VB text file.

With regards to VB, I think I'm better off trying to learn the basics rather then copy_in sections of code and debug any errors. I know this is going to be much slower but I should come out the other end of a learning curve with a much better understanding of programming in general. Time is not an issue here with this project, I've got until next Spring really, so with Winter to get through I should have plenty of time to learn.

Do you think this is the most sensible approach here, or am I going in to deep?

Also for any 'newbie VBer's, I came across this the other day, starts right from the beginning:

http://www.homeandlearn.co.uk/net/nets1p2.html

Dave

mackrackit
- 24th August 2010, 01:07
Sounds like a good plan to me.

I will go back over the RF stuff in a day or so ( I do not have those modules) and maybe we can get them going soon.

In the mean time maybe you could bread board a chip with it's own power supply serialing out a random set of numbers every few seconds , make sure serial communicator/ hyperterminal can "see" it. That will then be the test signal for VB.

Two projects going at once... Get flustered with one drop back to the other.....

?????

LEDave
- 24th August 2010, 14:46
Sounds like a good plan to me.

Thanks for that mackrackit, I was a little uncertain as to which way to go.


I will go back over the RF stuff in a day or so ( I do not have those modules) and maybe we can get them going soon.

That would be great. I've managed to get them to tx/rx as per Bruce's code and I have two sets of PDF's (full & abridged).


In the mean time maybe you could bread board a chip with it's own power supply serialing out a random set of numbers every few seconds , make sure serial communicator/ hyperterminal can "see" it. That will then be the test signal for VB.

I'll be on it tonight:)

Cheers: Dave

LEDave
- 24th August 2010, 19:06
Hi mackrackit,

The PIC is wired independently and the USB - Serial communicator displays the numbers as per the COM port on the old pc, so no problems so far.


ANSEL = %00000000 'Disable analog select so ports work as digital i/o.
CMCON0 = %00000111 'Disable analog comparators.
TRISA = %00000000 'Set PORTA as OUTPUT.
PORTA = %00000000 'Set PORTA pins all low.
TRISC = %00000000 'Set PORTC as OUTPUT.
PORTC = %00000000 'Set PORTC pins all low.


DEFINE OSC 4

X VAR WORD
Y VAR WORD
Z VAR WORD

main:
Random X
Y = X * 1000
Z = DIV32 21845
SEROUT2 PORTC.3, 16780, [DEC Z, 10, 13]
pause 4000
GOTO MAIN

Dave

mackrackit
- 25th August 2010, 04:10
I would say now on the VB part to start with a simple terminal type program to display the serial data like Serial Communicator does. Worry about data saving and stuff later.

LEDave
- 25th August 2010, 10:36
I would say now on the VB part to start with a simple terminal type program to display the serial data like Serial Communicator does.

Ok, I'll stick with / at it and see what I can come up with.

Dave

LEDave
- 26th August 2010, 22:24
Hi mackrackit,

Just to let you know I've been spending hours going through the VB exercises and taking notes in the hope that I'll eventually be able to get the PIC - VB program working.

Although it's time consuming, it's not time wasted in my view as there are some of the basics I still don't fully understand.

Dave

mackrackit
- 27th August 2010, 12:13
Have you ran across any good VB forums yet?

LEDave
- 27th August 2010, 16:12
Hi mackrackit,

I've just posted a question on the PIC / VB thread.

http://www.picbasic.co.uk/forum/showthread.php?t=13609&p=93080#post93080


Have you ran across any good VB forums yet?

I'm must have been through half of Google HDD's trying to find a 'ready made' solution, I never thought to actually 'join' a VB Forum:o

Dave

mackrackit
- 29th August 2010, 18:41
If you are interested I started some Python stuff at the web site in my signature.
I will be adding more as time permits.

LEDave
- 29th August 2010, 23:03
Hi mackrackit,


If you are interested I started some Python stuff at the web site in my signature.

Short answer is yes I am interested and thanks for posting the link. Right now I've managed to get a VB-2008 program to open and close Port_Com1 when I run debug, which is a breakthrough. If I can get it to receive data from the PIC then.......:) But so far no luck....:(

Give me a few more days to try and crack it, if I can't I'll jump ship to Python (I might do that anyway).

It's a shame that the 'RENTRON'? "Receiving Data From A Microcontroller" program was a different VB version, I'd just about got a handle on it in the broadest of senses, ho hum.

The VB stuff has been good for me though, it shows up the gaping wholes in my knowledge bank, you really can't run before you can walk with this stuff. Ill keep taking the small steps though.

Just to add, when I open Com1 in VB, then try to open Com1 with serial Communicator, it show the Port in use. When I close Com1 in VB, I can then open it with the Serial Communicator. I'm using this as a test / check.

How big a step forward is getting the Com Port to open and shut?

Cheers: Dave

mackrackit
- 30th August 2010, 04:24
How big a step forward is getting the Com Port to open and shut?
Sounds like you are getting there.

I did download VB 2010, looked at it a bit, watched a tutorial or two, and shut it down.

If you are learning from scratch and do not mind windows only then keep at it. IMHO

LEDave
- 30th August 2010, 16:26
Sounds like you are getting there.

I've got that sinking feeling there's some way to go yet. It would be nice to be pleasantly surprised though.

I think it (the program) needs some sort of event handler / buffer to store and read the data_in in bytes and then make words.


If you are learning from scratch and do not mind windows only then keep at it. IMHO

I'll stick at the VB2008 for now and see what I can 'cobble' together.

Dave

LEDave
- 2nd September 2010, 10:14
Hi mackrackit,

I've now become officially obsessed with getting the VB program to receive data from the PIC. I'm going to stick at it until I do. I still haven't got much beyond opening and closing the COM port at the moment though, still doing loads of reading.

I'll get there (one day).

Dave

mackrackit
- 2nd September 2010, 11:46
officially obsessed
:D
Probably not something for a business card.

Opening and closing the port. Sounds like you are almost there.

LEDave
- 6th September 2010, 00:13
The worlds most 'Obsessive' but slow programmer has now got a ' ListBox' that is receiving data from the PIC. Ok, it's mainly gibberish interspersed with the odd number but it's progress (I know, evolution happens faster then my programs:eek:)


Probably not something for a business card

I agree. How about a perfume....? Maybe not thinking about it:)

Dave

mackrackit
- 6th September 2010, 01:25
COOL!!!!
But why are you sending gibberish to the PC? :D

yea, a par fume. Love that new chip smell :)

Just wondering if the VB program has the port set different than the chip?

LEDave
- 6th September 2010, 10:06
Hi mackrackit,

The VB Port is set at:


SerialPort1.PortName = "COM1"
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.BaudRate = 2400
SerialPort1.DataBits = 8
SerialPort1.StopBits = 1

The PIC is:


SEROUT2 PORTC.3, 16780, [DEC z, 10, 13]

Does that look ok?

Dave

mackrackit
- 6th September 2010, 11:39
That looks correct to me.
Is this using the USB converter?

LEDave
- 6th September 2010, 12:34
Is this using the USB converter?

Yes it is. The PIC to serial Communicator via the USB converter worked 100%, which was a good bench test for the VB program.

I've modified the PIC program to transmit a RANDOM BYTE rather than a RANDOM WORD code below:


A VAR WORD
X VAR WORD
Y VAR WORD
Z VAR BYTE

main:
Random A
Y = A * 100
X = DIV32 25700
LET Z = X

SEROUT2 PORTC.3, 16780, [DEC z, 10, 13]
pause 4000
GOTO MAIN

PYTHON might still be the answer yet.

Dave