Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:57 23 Nov 2024 Privacy Policy
Jump to

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

Forum Index : Microcontroller and PC projects : Anyone want to help test my I2c code

     Page 1 of 2    
Author Message
ksdesigns

Senior Member

Joined: 25/06/2011
Location: United States
Posts: 143
Posted: 04:55pm 07 Jul 2011
Copy link to clipboard 
Print this post

My compile of the Maximite 2.4 code with i2c Download Here

Uses hardware i2c port so add 4.7k pullups to pins 43 and 44 of the pic or pins 12 and 13 of con 8

pin 12 - SDA pin 13- SCL

Added commands

i2cinit(bus speed in khz 100 or 400) <- must be called first also allocates i2cbuf(64)

i2cwrite(device address, memory address,data,data,data,data)

i2cread(device address,start address, length) data will be in i2cbuf()

after doing i2cread or i2cwrite check MM.i2c if bit 1 is set means there was no ack from the i2cdevice

example code inits i2c reads 10 byes from eeprom from location 0

10 i2cinit(400)

20 i2cread(&HA0,0,10)

30 for t= 0 to 9

40 print hex$(i2cbuf(t))

40 next

Any Feedback would be great thanks
ken
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 05:01pm 07 Jul 2011
Copy link to clipboard 
Print this post

ok so i load yor code into my bott stap but then what do i di i dont see any way of connectting a printer un less i plug it into the usb

technicians do it with least resistance
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 05:11pm 07 Jul 2011
Copy link to clipboard 
Print this post

ok so if i run your prog then what am i expected to get ..dont worry i will do it in about 5 min`s but i dont know what you are expecting to to get pls reinform me here ..regards sparkey....
technicians do it with least resistance
 
donmck

Guru

Joined: 09/06/2011
Location: Australia
Posts: 1313
Posted: 05:14pm 07 Jul 2011
Copy link to clipboard 
Print this post

  sparkey said   ok so i load yor code into my bott stap but then what do i di i dont see any way of connectting a printer un less i plug it into the usb


Sparky, Ken is asking people to test his code for his new I2C commands.

It has nothing to do with a printer, the "PRINT" command is to output data to the screen which has been read from the I2C port.

And you can't connect a printer to the Maximite without dramatic software changes, possibly even hardware changes.

But what I can't understand is why you would want to, unless you have a specific embedded application that requires printer output.

If you need to print a BASIC program, just print it on your PC.

And Ken, good luck with this. I know of several people really wanting I2C.

I have never used it. I know transmission length it is about capacitance, and number of nodes, but what distance would you expect? I assume it would run around an average home.


Cheers Don...
Edited by donmck 2011-07-09
https://www.dontronics.com
 
stuarts

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 199
Posted: 05:18pm 07 Jul 2011
Copy link to clipboard 
Print this post

Ken, I have some I2C code running in basic. just one question. if I am using a DS1631 thermometer, to read temperature, I have to be able to send a

start condition, device address with write set,access temperature command,repeated start condition, device address with read set, read temp high byte, read temp low byte.

I dont see how I can do this with your commands.

Stuart
Time is nature's way of keeping everything from happening all at once.
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 05:20pm 07 Jul 2011
Copy link to clipboard 
Print this post

thanks don..regards sparkey and hello and hope you r well
technicians do it with least resistance
 
stuarts

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 199
Posted: 05:22pm 07 Jul 2011
Copy link to clipboard 
Print this post

Ken, I'll be sure to test it with the 16 bit parallel board I've got running. Looks like that will work really well.

Stuart
Time is nature's way of keeping everything from happening all at once.
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 05:29pm 07 Jul 2011
Copy link to clipboard 
Print this post

stuart there is some basic programs in i think may 2011 sil chip that allows you to use a "lm335" if i am correct i ...i..riogged one up on my coommydoor wicch cut in the theremo fans atr about 90 degresse... ..maybe i`m of par here so if i got it wrong disregard this message
technicians do it with least resistance
 
ksdesigns

Senior Member

Joined: 25/06/2011
Location: United States
Posts: 143
Posted: 05:31pm 07 Jul 2011
Copy link to clipboard 
Print this post

Stuart
try this
10 i2cint(100)
20 i2cread(device address,command byte,1)

that will do a start, device address with write but set, send command byte, restart, device address then read 1 byte after that then a stop
and you data will be in in2cbuf(0)

ken
Edited by ksdesigns 2011-07-09
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 05:47pm 07 Jul 2011
Copy link to clipboard 
Print this post

ok i`m about to run your file list programme ..regards sparkey ....using mm.2.4a

technicians do it with least resistance
 
ksdesigns

Senior Member

Joined: 25/06/2011
Location: United States
Posts: 143
Posted: 06:12pm 07 Jul 2011
Copy link to clipboard 
Print this post

Don
i2c is not good for distance , for that dallas one wire would do much much better for distance 60m wold be easy using cat5 cable

the dallas ds18b20+ works very well
i have lots of onewire code but that's whole other can of worms getting it to work on the maximite.

ken

 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 06:14pm 07 Jul 2011
Copy link to clipboard 
Print this post

it would not run

i`m tiored and just standing over a KB atm will try latrert

technicians do it with least resistance
 
ksdesigns

Senior Member

Joined: 25/06/2011
Location: United States
Posts: 143
Posted: 08:57pm 07 Jul 2011
Copy link to clipboard 
Print this post

Should mention this is a full firmware based on 2.4 so you will have to reflash you board with it .. using the bootloader
ken
 
donmck

Guru

Joined: 09/06/2011
Location: Australia
Posts: 1313
Posted: 10:07pm 07 Jul 2011
Copy link to clipboard 
Print this post

  ksdesigns said   Don
i2c is not good for distance , for that dallas one wire would do much much better for distance 60m wold be easy using cat5 cable

the dallas ds18b20+ works very well
i have lots of onewire code but that's whole other can of worms getting it to work on the maximite.

ken

Thanks Ken, another of my favorites for distance is RS-485:
Maximum Devices 32 drivers or receivers
Maximum Distance 1200 metres (4000 feet)

That's because I have used it and have run 500+ terminals on it. Betting terminals on a horse racing track. Multiple UARTs of course.

For the locals:
I was paid to go to 25 Melbourne cups, to run the main computers, and had to suffer the eye candy. A tough job for a young man. :-)

We may have driven it 2000+ metres. Flemington Paddock "A" to the ELMs one way, and well up into the Members car park in the other direction.

For Maxiteers:
Basically this is just a change of hardware, from what would normally be the output of a UART that would drive RS-232. So you need serial comms to get RS-232 or RS-485 working.

I see RS-485 as the magic bullet that will monitor up the windmill, down the workshop, in a dungeon, up the attic, the power generator, solar panels, shearing shed, and of course most importantly, whatever.

Then there are radio modems, but baby steps first.

Cheers Don...
Edited by donmck 2011-07-09
https://www.dontronics.com
 
ksdesigns

Senior Member

Joined: 25/06/2011
Location: United States
Posts: 143
Posted: 10:20pm 07 Jul 2011
Copy link to clipboard 
Print this post

Don
what i was thinking of doing since the i2c works for me, was going to use a small pic16f1822 (8pin part) to go from i2c to serial and onewire
just as a little extension to the maxmite and that uart in that part will do 9bit addressing for RS485
ken
 
stuarts

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 199
Posted: 12:46am 08 Jul 2011
Copy link to clipboard 
Print this post

Ken, I've been looking at the DS2482-100 I2C to 1wire bridge. It does all the 1wire timing for you. There is also the DS2482-800 which is an I2C to 8 x 1wire.

I've got some of the -100, I just haven't any other 1wire devices to talk to yet.

Stuart

Time is nature's way of keeping everything from happening all at once.
 
donmck

Guru

Joined: 09/06/2011
Location: Australia
Posts: 1313
Posted: 02:26am 08 Jul 2011
Copy link to clipboard 
Print this post

  ksdesigns said   Don
what i was thinking of doing since the i2c works for me, was going to use a small pic16f1822 (8pin part) to go from i2c to serial and onewire
just as a little extension to the maxmite and that uart in that part will do 9bit addressing for RS485
ken


Ken, just off the phone to Stuart,

He is pretty sure we don't have a UART pair on the 20 pin I/O bus, so we may have to go I2C as you suggested.

You can get an I2C to UART chip, then just add your 232 or 485 driver chip, or do as you say with a PIC chip.

Either way, it sounds workable with 3 ICs:

MM-I/O> I2C > UART > RS-232
MM-I/O> I2C > UART > RS-485
MM-I/O> I2C > PIC > RS-232
MM-I/O> I2C > PIC > RS-485

Cheers Don...


https://www.dontronics.com
 
donmck

Guru

Joined: 09/06/2011
Location: Australia
Posts: 1313
Posted: 08:31am 08 Jul 2011
Copy link to clipboard 
Print this post

  ksdesigns said   Don
what i was thinking of doing since the i2c works for me, was going to use a small pic16f1822 (8pin part) to go from i2c to serial and onewire
just as a little extension to the maxmite and that uart in that part will do 9bit addressing for RS485
ken


Ken, after again chatting with Stuart, I did a google and came up with this:

http://forum.sparkfun.com/viewtopic.php?p=26247&sid=1e143620 78e41b73a4e3f3bdd9ad523a#p26247

Here is the thread message, but the thread is interesting anyway:

[code]
One approach is to do this with a 16F88. It has a UART and I2C that are on separate
pins. And you can use the leftover pins to interface with other stuff. And you can
put code in the F88 to 'filter' or 'buffer' the serial data (or whatever you might
need). Since the F88 is always a Slave, hook up an I/O pin back to your main CPU, so
that the F88 can interrupt you if data arrives on its serial port. A dedicated
I2C-to-serial chip would be simpler, but not nearly as flexible.

I think the 16F88 is the smallest chip that has 2 kinds of serial interfaces on
separate pins. There are a lot of bigger choices.

I recently did something similar to what I described above, but used a dsPIC30F4011
- it gave me *two* UART ports, and I talk to it via I2C from an 18F4620 (it's the
I2C Master). The 4620 has a UART of its own, so the board has a total of 3 UARTs,
plus I2C, plus a boatload of I/O pins, plus the dsPIC engine which can run at up to
120 Mhz to do fancy math or whatever. The dsPIC interrupts the 4620 when it wants
attention.
[/code]

Cheers Don...
https://www.dontronics.com
 
stuarts

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 199
Posted: 01:19pm 08 Jul 2011
Copy link to clipboard 
Print this post

Ken, I'm going to miss my edit command from 2.4a..... Glad I've got a few maximites to run different firmware on


Stuart
Time is nature's way of keeping everything from happening all at once.
 
donmck

Guru

Joined: 09/06/2011
Location: Australia
Posts: 1313
Posted: 02:39pm 08 Jul 2011
Copy link to clipboard 
Print this post

  ksdesigns said   Should mention this is a full firmware based on 2.4 so you will have to reflash you board with it .. using the bootloader
ken


Ken, I sent a copy of your original email to me, onto Geoff Graham.

As you may know, Geoff may go a week or two at times between internet windows.

My concern is he mentioned doing any potential update to the firmware in a modular fashion, so he can incorporate them into his build.

I forget his exact words, and I would need to chase the thread, but I knew what he wanted. Wonder if you have this covered, as your work, could save him a lot of time, and allow others to get into I2C comms a lot quicker that expected.

Thought I would mention it in the open Forum, so that others are aware of what Geoff needs.

Cheers Don...


https://www.dontronics.com
 
     Page 1 of 2    
Print this page
© JAQ Software 2024