Just build my MCP2200 board and I am using it for RS485 communication with automatic TX switchover (half duplex bus).
I added a p-channel mosfet to switch the transceiver from receive to send when a low signal is on the uart TX (it goes to GND when sending). Works great and no software is required on the PC for working with RS485. Well, it probably should listen if there is communication on the bus and only send if there is not, but it can be implemented in hardware as well.
Tested it with my PIC on RS485 with ds30loader, could easily flash the PIC! ds30loader is modified to work with RS485, so it uses a TX_Enable line. ;)
HiZ>~ Disconnect any devices Connect (ADC to +3.3V) Space to continue Ctrl AUX OK MODE LED OK PULLUP H OK PULLUP L OK VREG OK EEPROM SCL OK SDA OK WP OK ACKADC and supply Vusb(4.91) OK 5V(4.93) OK 5V0 VPU(4.38) FAIL ADC(3.29) OK 3.3V(3.27) OK 3V3 VPU(2.77) FAIL Bus high MOSI OK CLK OK MISO OK CS OK Bus Hi-Z 0 MOSI OK CLK OK MISO OK CS OK Bus Hi-Z 1 MOSI OK CLK OK MISO OK CS FAIL MODE, VREG, and USB LEDs should be on! Any key to exit Found 3 errors.
Nevermind the voltages being too low, this is probably because I used different transistors and need to change the base resistor or so. ;) This doesn't bother me. CS is the problem here. I checked for solder bridges, but everything is ok. CS is connected to the PIC fine. How can I check the components? The CD4066BM is new, somewhere from china. I ordered some on ebay.
The soldering is not my best job, but since I moved here this month I can't find my good solder. ;) Picture of my build:
Pushbuttons are from a laptop repair I did some months ago, where I had to order 10 and only needed one for the repair. ;) CD4066 is from ebay, and the rest of the components were around. Some are 0805 on 0603 pads, not pretty but works.
Maybe this inspires someone to also build it as a gift. :D
Some info: tvbgone firmware from Ian (irtoy) which works like a charm here. 10 IR LEDs from Vishay (some high power stuff afair) in parallel pulsed with up to 4.2V from the battery! I Think the only voltage drop or resistor is in the mosfet I used. ;)
Had to add 2 capacitors in the battery lines so that the pic doesn't crash while transmitting. (Note: the capacitor by the LEDs is NOT connected to the LEDs but before the mosfet.)
The case is a old pvc pipe i found in my garage. I cleaned it and sprayed it (including a high glossy clear paint) so that it looks better. ;) A simple pushbutton glued from the inside trough a hole is to control the pic.
Battery is a 17670, a slightly slimmer 18650 which is normally in the most laptop battery packs. Glued to the battery is a miniUSB jack with a MAX1811 and a blue LED which indicates charging. While full charged and connected to USB, the blue led flashes when sending IR. Looks really nice ;). This is just because the voltage drop from the IR LEDs.
The IR LEDs get a bit warm when sending for a while, but still work after a couple of months intensive use. :D
Range? A lot! At home I can point it in every direction and my TV goes off. Haven't tried it in a huge shop yet. But could be fun. :)
I prefer using the Flash so I don't need to have a couple of µSD (and I always end up killing them somehow) and now I have enough storage. ;) Don't really need 2GB or so. Hopefully this helps somebody.
Hi, Has anyone here used software I2C with the Web platform? I would like to add some GPIOs and other stuff which uses I2C, but cannot use hardware I2C since the data PIN is on one of the EEPROM Pins! (And connot be remapped)
I was wondering why the web platform can't reset the PIC for entering bootloader automatically with the FTDI chip? I mean I am wondering why this wasn't implemented.
I found a reset tab in the ds30 Loader tool which pulls a pin (RTS or DTR) low for reset when you klick on "Download". So I soldered a wire from DTR (pin 2, FTDI chip) to MCLR and tried it:
Worked fine. Now I don't need to press the reset button when I want to upload a new firmware. (that was annoying while developing stuff)
Tested it with external power, too. Works fine. (I had feared that the FTDI chip somehow resets the PIC when not powered by USB or whatever) The PIC resets when powered by external supply and USB is plugged in, but thats not really a problem.
So if you have a steady hand just solder a wire and be happy. :) Or: you can reset the PIC by serial command... but that doesn't involve soldering, so it's not that cool. :D
After playing around with my web platform I thought I can post some code that maybe help somebody. :)
My project with the web platform is to develop new features and implement them in my actual home automation. In my living room I can control some light (12V) with a couple of MosFETs on "old" 18f97j60 ethernet board. Controlling remote outlets currently is done quite dirty. (Bit banging an PT2262 remote IC)
I knew this could be done with only one pin and much cleaner!
You can see my code at the end of this posting.
Calling the function with: send_rf(0b10010011, 0b0100);
To be honest, you need to have at least a little bit understanding how to configure the function call, but I can help you with that. ;) It's quite easy.
RF is defined as an output pin. (of course!)
Works here at my home flawless! My test rig:
To see what exacly is being sent:
The blue capture is from my PIC and the yellow one is from an original remote control! (But different keys were pressed/sent) Just to see the timing ;).
I am using this transmitter module with much power: link but standard modules like this are fine, too. If your transmitter has a RF encoder chip on it, you have to cut the "RFout" wire from it and connect your PIC with the end of the wire that goes to the circuit.
I welcome questions and/or criticism on my code. The 8 bit variable is used so I can directly control it over uart! (on my PIC12F for example)
#define FOSC 80000000LL #define FCY (FOSC/2) // MCU is running at FCY MIPS #include "libpic30.h"
void send_rf(char conf1, char conf2) { int i, j; char conf1a, conf2a; conf1a = conf1; conf2a = conf2; j = 0; for (j=0; j<5; j++){ // repeat sending 5 times. //This is needed by the PT2272 receiver (at least 3 times iirc) conf1 = conf1a;// store data to send conf2 = conf2a; for(i=0; i<8; i++){ // parse data from conf1 and send via RF (right to left)
switch (conf1 & 0x01){ // one bit at a time! case (0): { // send as float RF=1; __delay_us(300); RF=0; __delay_us(900); RF=1; __delay_us(900); RF=0; __delay_us(300); break; }
case (1): { // send as 0 RF=1; __delay_us(300); RF=0; __delay_us(900); RF=1; __delay_us(300); RF=0; __delay_us(900); break; } } conf1>>=1; // shift conf1 right to parse next bit } for(i=0; i<4; i++){ // parse data from conf2 and send via RF // only the lower 4 bits are needed.
switch (conf2 & 0x01){ // one bit at a time! case (0): { // send as float RF=1; __delay_us(300); RF=0; __delay_us(900); RF=1; __delay_us(900); RF=0; __delay_us(300); break; }
case (1): { // send as 0 RF=1; __delay_us(300); RF=0; __delay_us(900); RF=1; __delay_us(300); RF=0; __delay_us(900); break; } } conf2>>=1; // shift conf1 right to parse next bit } // done with data, now a sync is needed. RF=1; // sync __delay_us(300); RF=0; __delay_us(9690); // weird time, I know... } }
I was wondering if anybody has tried an internet bootloader on the webplatform?! The one I found from microchip is for the 18f97j60 chip. I found some commercial bootloaders, but nothing free.
It would be very nice to automatically load a firmware every reboot if a new file is on a tftp or something.
thanks in advance.
PS: I just ordered my web platform and I am interested in testing it out. I was to lazy to make my own board, have already worked with 18f97j60 with internal ethernet. My own ethernet board currently controls my lights at home.