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 : PIC based I2C devices.
Page 2 of 3 | |||||
Author | Message | ||||
muddy0409 Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 125 |
No, never done anything in assembler since the old VIC20 and C64 6502 stuff. (geez, now I'm showing my age). BTW not the slightest interest or plan to re-learn assembler of any way shape or form. I ONLY use PBP these days. If I can't do it with PBP I'll simply relegate it to the round filing cabinet and go on to other projects. I've got a Melabs USB programmer and a PicKit2 for programming. PBP appears to have I2C functions, so I'll use that. If that seems unsuccessful, I'll just go back to using parallel control of everything like I do now. Don't poo poo conspiracy theories. Remember that everything ever discovered started somewhere as a theory. |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
I'm showing my higgerance ere, but what is PBP? Pic assembly language is dead easy - only has about 34 instructions divided into roughy two types i.e. direct (literal) or file. That means there are only about 17 instructions to come to grips with and you mainly only use 5 or so of those. I wrote my own assembler/programmer, but MPLAB and MPASM work quite good for both writing code and programming the PIC. I write mine using "notepad" text file and let the assembler/programmer do the rest. I admit it is getting harder to keep up the enthusiasm and not just relegate things to the round file particularly when I have no like interaction. That's why I joined this forum. I wanted to start an electronics group in my district but lots of advertising and two years later (more now) and not a nibble. The town recently started a "men's shed" but so far it is all wood and metal work - no intellectual stuff. Mostly somewhere to go for a cuppa and a chin wag. David M. |
||||
BobD Guru Joined: 07/12/2011 Location: AustraliaPosts: 935 |
I'm wondering what PBP is too. I Googled but the best answer I found there was Penicillin binding proteins and I suspect that is not the answer. |
||||
djuqa Guru Joined: 23/11/2011 Location: AustraliaPosts: 447 |
And to get away from the "Wife". I have had same experience, mention anything other than "Furniture/pottery/Barbie Dolls/Nail Art /Hair Braiding" at a OldGirls Shed like electronics, radio, computers, cars or hunting & it is like I mentioned Devil Worship. Very depressing, which is serious considering it is supposedly good for men to have these type of activities to help with DEPRESSION. Thankfully we are all part of the online "Back Shed" community already, VK4MU MicroController Units |
||||
CircuitGizmos Guru Joined: 08/09/2011 Location: United StatesPosts: 1425 |
PIC BASIC Pro? Micromites and Maximites! - Beginning Maximite |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
Yes, I just did a google too and it looks like that is right. A basic compiler. Never really sure with a compiler if the resultant code is as efficient as it can be, particularly if timing is critical. I guess my I2C devices could be translated to PicBasic Pro but why would you when pic assembly is relatively easy (at least in the 8 bit series). It is very easy to write a basic programme and translate it to PIC assembly. In fact, when I write a pic (or atmel) assembly programme, I write it first in "basic" to develop the algorithm and use the "basic" to act as assembly language comments. I don't know whey many people baulk at assembly language particularly when it is a simple as the PIC instruction set. David M. |
||||
donmck Guru Joined: 09/06/2011 Location: AustraliaPosts: 1313 |
Here is a little rundown on PBP: http://www.dontronics-shop.com/picbasic-pro-compiler.html Don... https://www.dontronics.com |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
Hi Don, I had a read through PBP on your site and it looks quite impressive and reasonably priced too. I like the ability to be able to access file registers by name - almost as good as pure assembly language. I saw a PDF of the manual on google, might have to download and have a read in my "spare time" Mind you , it probably won't stop me using straight assembly language as old habits die hard. I would like to have a go at translating one of my I2C devices to PBP just to see if it works and is more attractive to budding PIC users. David M. |
||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
Mention CNC and see if you get any interest. James My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
Worth a try. I have a CNC machine (thanks Downwind) but I wouldn't let it loose on the calibre of inmates at the present and I can't see any having a go at constructing one - time will tell. David M. |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
CNC is so 'old skool'. 3d printing is what is hot. At least in my area CNC does not arouse any curiosity but now that friends know that a 3d printer is on its way they are very excited. It is strange because for the wood and steel guys a CNC is a great tool. Back to I2C. I agree that the PICs are not that hard to program in assembly, but it is even easier in C. As microchips compiler is optimized the resulting hex file is pretty fast and comes very close in performance to assembly. My plans for the TZBlox is a range of I2C/Serial modules. I actually find the serial TX/RX/GND connection even easier to use and it is a pity that the VGA on the CMM prevents using all of them that are available in the PIC32. Believe it or not but there are six! uarts in the PIC32. They all have interrupts for receiving and send buffer empty making programming them a breeze. Another reason i like serial is because i can hookup a terminal on it and see what the device sends and can type in commands with a keyboard. Makes debugging much easier. Using PICAXE chips to interface something like a 1-wire or LCD is supereasy as they have lots of builtin functionality and can be programmed in basic. A good match with the CMM i think. The I2C is great when you don't have the pins and wiring is easier. The protocol however is more difficult and you need addressing which needs board space when you want to use more then one of the same device. As MOBI has already done the hard part it is not difficult anymore to make a slave device. Thanks MOBI! Microblocks. Build with logic. |
||||
Bryan1 Guru Joined: 22/02/2006 Location: AustraliaPosts: 1345 |
Well while I was building my CNC I did do a heap of research on 3D printing (reprap) only to find it uses the arduino (YUK) anyway now my CNC is finally up and going now I got that 300 waat 12-48 cnc spindle mounted but sooooo busy at work a day off seems a distant memory.... The bathroom I'm currently doing turns out the husband who gets home from hospital tomorrow is a TAFE teacher for 3D cad and 3D priniting so I can see some good convo's coming up in the next few days picking his brain on the subject. Now since this thread has drifted off to Basic I have to mention what I use and thats Oshonsoft Basic. The best part of it is the simulator and one can build external modules in VB to act with the simulator too. I2C is easy as too and in the near future the compiler will have a new update to suit the newer pic chips too... Cheers Bryan |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
I live in a rural town where most of my friends are farmers or in the agri business one way or another and trying to get them to use anything technical is hard enough let alone build it. The CNC machine I have was built primarily for drilling home grown PCBs but will do small engravings like desk name plates etc. I suppose I better get busy and put my I2C master firmware up for use/criticism. It may not be the best way to do things but it works. My first attempt at building a I2C module was using a PIC16F84A which doesn't have I2C facilities. I used a 74LS00 with a resistor/capacitor mono to generate an intedg (port B0) trigger to indicate when an I2C start condition was present. The rest wass all done in firmware. Never missed a beat. David M. |
||||
muddy0409 Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 125 |
Yep, you're right...PBP = Pic Basic Pro Compiler. I,ve been using that now for some 10 years ago, with I think 2 upgrades from Dontronics. It's from Micro Engineering Labs and suits me right down to the ground. I havedn't yet had anything that I couldn't do with PBP, which just goes to show how few projects I do actually do, I suppose. Between PBP and the Melabs USB programmer there are not many PICs that it wont program, noteably the 32F series but I don't think I'll be doing anything with them. (boy I'm starting to sound like a sales pitch aren't I?) Don't poo poo conspiracy theories. Remember that everything ever discovered started somewhere as a theory. |
||||
donmck Guru Joined: 09/06/2011 Location: AustraliaPosts: 1313 |
I have been a part of PBP right from the start. Parallax had the basic stamp one, and Melabs developed their standard Pic Basic Compiler, (1994-1995?) so that more could be achieved by burning your own chips with PBC. It would run faster, allow more code, and if the users wanted multiple micros for a project run, you only needed to purchase a micro, compile your code, burn the micro, with no need to purchase a basic stamp each time. This soon evolved into PBP (PRO), which is used in many applications including consumer products. PBP may be a little expensive, but it allowed developers to get into PIC projects, and produce great code, without much in the way of programming skills or experience. I currently have all Melabs compilers and PIC programers at 5% off Melabs standard retail prices. http://www.dontronics-shop.com/micro-engineering-labs-m20.ht ml As a TBS member, If you mention "The Back Shed", during the purchase, I'll offer an additional 15% off my current prices. Don... https://www.dontronics.com |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
There has been a bit of interest lately regarding the Maximite (and other) I2C bus. I have found over the last few years that most hobbiests tend to shy away from it as "too hard". Before you read on, I advise you to have a read of the section on I2C in the Maximite Language Manual. It looks complicated and to a degree, it is but.. basic I2C without all the bells and whistles (interrupts, time-outs etc.) is really quite simple and most hobby knockups will work faultlessly. What is I2C? Simply it stands for :inter integrated circuit and is a way of communicating between mainly micro controller based ICs. All I2C devices are an MCU based device. The bus consists of two wires namely, bi-directional serial data (SDA) and a serial clock pin (SCL). All data is clocked at the SCL rate which can vary in speed without upsetting the data integrity unlike e.g.the RS232 bus in which all devices must be operate on a predetermined baud speed. In a simple system, generally, there is only one master controller with up to 127 slave devices. That is more than enough for the hobbiest. In "old fashioned" serial comms, the data is asynchronous, i.e. it is start stop for each byte sent. Transmission is initiated by pulling the data line low for one bit length (start space) followed by 8 bits of data and terminated by a high (stop mark) of at least 1 bit length. Subsequent bytes follow the same format until all data is sent. In I2C, we still need a start and stop signal but this time, we use both the SDA and SCL lines. To send a "start" signal, the SDA line is pulled low whilst the SCL line is still high. A "stop" signal is sent by pulling the SDA line high while the SCL line is already high. When a start condition is initiated, all I2C devices on the I2C bus prickup their ears waiting for the first byte sent which is always an "address" byte. Every device on the bus has its own unique "address" and a device whose address matches the the first byte sent will acknowledge (ack) by pulling the SDA line low while the master sends a 9th clock pulse to read the ack. The LSB (bit 0) of the address byte is direction (read /write) bit which tells the slave it has to either receive (/write) or provide (read) data. Once a selected device has acknowledged its presence, the master has its undivided attention and all other slaves carry on doing their own thing. Bit zero of the address byte is the read/write bit and determines whether data is sent or received. The master then sends or receives the number of serial bytes it requires and then sends a 'stop' to the bus which puts all devices back into 'listen' mode again. Devices include: Real time clock, EEPROM, data expander,LED and LCD displays..etc. A good way to get information on the i2c system is to download a datasheet on any i2c device e.g. DS1307 real time clock. That will show the timing waveforms and data format for I2C in general and the RTC in particular. The data (SDA) and clock (SCL) are each pulled high via a (nominally) 5Kohm resistor. This provides the logic '1' signal as the transmitter output is switched to 'high impedance' mode. This is done so that a 'hard' '1' and '0' can not appear on a signal line at the same time saving that very valuable "magic smoke". If you are just a I2C user (plug and play) you don't need to know all the wave forms and timing etc, just the command structure. Although the basic data format is common from device to device, there are subtle variations as to the order and number of data byres sent/received. If you are "into" MCU programming, this topic will eventually lead to writing the MCU code for an I2C slave. I will use the PIC16F88 but any MCU with I2C functions will work if you want to do the code translation. The principle is the same. David M. |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Hi David, I think a few of the chip companies could do with paying you to write their datasheets - that's as succinct and understandable a description as I've seen of how I2C works. I have managed to get a few devices going in the last year or two but I could have saved some hair if I'd been able to read this first! Greg |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
Thank you. Flattery will get you everywhere. Most data sheets IMO are written by engineers for engineers. I came up through the ranks in the RAN to end up as an electrical engineering officer (not boasting) and found myself on the receiving end of much ambiguous technical data before I got to the dizzy heights of producing it. I read and re-read the post a good many times before I felt that the majority would understand. I better get busy and compile the next episode. David M. |
||||
elproducts Senior Member Joined: 19/06/2011 Location: United StatesPosts: 282 |
I've used PicBasic and PicBasic Pro since it's release. I was even a beta tester for PBP and wrote a few books on how to use it. It's a great product. In the last year though, I've been using Great Cow Basic which is an open source Basic compiler for PIC and AVR. What I love most about it (besides being free) is it produces pure assembly code. I can load the assembly code file right into Microchip's MPLAB IDE and debug in pure assembly using microchip tools and simulator. I don't have to modify the assembly file at all. Plus GCB has commands for reading keypads, PS/2 keyboard, driving graphic LCD, driving LED display and then most of the commands PBP has. But what's really cool is the ability to create your own functions so you can essentially create your own commands. I launched an informational site for it at: http://www.greatcowbasic.com I was beginning to work on creating functions that match the syntax of MMBasic so an I/O focused program written in MMBasic can be easily ported over to a smaller PIC. With the announcement of Geoff's Micromite, this may be a useless task. www.elproducts.com |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
I 2nd the motion! I had some issues when trying my first I2C devices, but that was becasuse I chose EEPROM chips - probably not the BEST I2C thing to START OUT on, as there are complications such as page-boundries to remember and not overwrite when page-writing, or data is lost - I had a bit of that, until I was helped to get my head around page-writing. I am still a bit confused by it all! Luckily, I don't have need to play with EEPROM's very much - yet. Smoke makes things work. When the smoke gets out, it stops! |
||||
Page 2 of 3 |
Print this page |