Jump to content

rfhaley

EstablishedMember
  • Content Count

    77
  • Joined

  • Last visited

Community Reputation

0 Neutral

About rfhaley

  • Rank
    Regular

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Location
    Edmonton, AB, CANADA
  1. Many most humble thankyous In a past life I used to teach introductory programming at university. Oldtimer's disease must be setting in early; I'm not even 52 yet. It works great with y = rand()%20+1; Mod 20 gives 20 remainders and +1 shifts from 0-19 up to 1-20.
  2. I have 20 leds and I want them to twinkle at random using a 12F629. My subroutine accepts an unsigned char between 1 & 20. The program is fine, no errors and blinks a lot of patterns except my random part. I have included rand...16...lib with no problems rand() returns unsigned short so it is 16 bits? or 0 to 65535? or is it a fraction between 0 & 1 like the rest of my world? I thought I could use unsigned char y = 20*rand() + 1; but it does not work. I also tried unsigned char y = 20*rand()/65535; with all sorts of tries at parenthesis to deal with possible overflows and such. All the info about rand in BoostC talks about the function not the results. How can I use the rand() result to get an integer number from 1 to 20 and convert that to unsigned char? I am guessing that division is always returning a zero somewhere. Any clues? Xmas is coming.
  3. Thanks. I think we're making progress. The EZ uses a bootloader so I thought it might be a loss of bootloader, but now it seems to be the jammed reset. My system sends 24V to one board that feeds the EZ and sends 5V back up the same Cat5 (15m) cable to another PIC. Power on sequence trouble would bother the second PIC but it does not. Power and ground are connected before power on and Never disconnected with the power on. For sure, disconnecting, with the power on, the Cat5 cable that carries power & ground will blow up the PICs. My entire project is a 128bit line follower that has a second PIC for remote potentiometer adjustments. It works well in Canada and can follow a fuzzy edged line on a cylinder while looking through a scratched, practically opaque window. Perhaps I should use RS485 and separate power supplies.
  4. Quite right. Microchip shows a list of troubles related to latchup. It turns out I have several EZ with burnt out reset pins. The 18F252 by itself shows a short to ground. I wonder what I have done? One of the bad chips was on a board that did not even connect the reset button. The EZ reset is pulled up by 10k and has a capacitor to ground. Still looking...
  5. I took 4 EZs from existing boards that were socket mounted intermediate prototypes. The first one would not accept a program until I clicked over and over, 6 times. Then it accepted the communication. I am using the cable that came with my devices and changing only the EZ dip (with the power off!). The second programmed right away. The last two will not accept a program no matter how many times I reset or reclick the Program button. The power LED is on for every chip but I am repairing my basement so my shop is in boxes. It does not matter whether I am in Sourceboost or running EZDownloader by itself. Are these bootloder memeories susceptible to Xrays at the airport? Could my bootloaders be corrupt?
  6. Thanks to both. I suspect there is trouble using my grounded design on an ungrounded 50Hz source, but I have no deliberate connections to case ground. My friend says there is powerline noise, at 50V to ground, on the ground side of his supply so maybe everything is toast or I should have used differential signals. His computer ground should be the same as the EZ due to the programming cable. The EZ is fed from a 24/5V switcher on my board and the 24V is isolated and comes from a PLC that is working. Sounds like a badproject...
  7. I programmed some EZ controllers here and sent them to a friend overseas. He tells me they don't work and he wants to re-program them. I watched him download some programs on his computer while he was here and he knows how to do it. He is describing a problem I have often encountered over the last few years of using the EZcontroller. The EZ Downloader stops and prints a message that it 'cannot communicate with device'. Many times this happens because I screwed up the I/O portB.1 & .3 pins so please ignore that as a response (He is just reloading software that I know is functional). He knows the polarity of the connector as well. We are using the EZ doenloader from the web site January 2007 and the EZ controller (20MHz) from Sourceboost. He is using a real COM port and I use a USB converter. Sometimes, every six months or so, I get jammed up by the same message and I reset the EZ to no avail. I reboot my computer and restart the EZ downloader but nothing changes. Sometimes I reset the EZ six times before I try to download again and it will not help. I check the cables and I have not fiddled with the COM port settings but I play there anyway.(115k Baud) THEN EVERYTHING WORKS! Nothing has been damaged. I don't know what I have done but I need to send better info to my pal than "my luck is better than yours" Has anybody else had this problem and worked out a logical answer? I am hoping he will see this post and read your replies (or join). Thanks for your patience if you read this far
  8. No, Really. I know what I want. I may not have convinced everybody else though. The forum search is fine. I just don't want answers that tell me to RTFM. I want an EZ controller (available from Sourceboost.com) to send USB info to a PC. The EZ already has a MAX232 and I can use it (and I have for two years), software and all. My SmartRelay will trip an interrupt on PortB, and depending on which pin caused the interrupt, send a text message over the USB. How could I use the MAX232 to send USB signals instead of rs232 signals? I have plenty of rs232 code already, I am looking for hints on USB code. I could just jam a USB/serial converter on the output but perhaps I could look smarter? Everything I have found deals with USB enabled PICs but I have the 18F252 available.
  9. Since I can't search a 3 letter term like USB on this forum I ask for hints. Can I make a USB connection to the EZcontroller? It is a PIC18F252 & has a max232 onboard but I know little about USB protocols. Has anybody made any code like the rs232 code in boostC?
  10. First, a 16F84 has a different part number than 16F88. This makes me wonder why. Try reading the data sheet on PortB, there is more to I/O than tris. RB3 is not available for I/O Unless you ask for it first. keep smiling and keep reading.
  11. 'Tell me, I forget Show me, I remember Let me do it for myself, I understand' I learned what I needed from the data sheet Read the chapter on Analog Converter, my comments for ADCON are directly from my data sheet. Try to calculate your own conversion delays. I would rather have somebody get me started with an example though.
  12. yeah, i misread that part ... haste makes waste i guess. <{POST_SNAPBACK}> You won't find many more hasteful or wasty than me. Not only do I discard adresl, some of the setpoints are >>3 because I want a fairly small range for some things. This also removes some jitter in the last bit as it requires many more turns of the pot to make the A2D output change. My LCD is only 122 wide so my 'center' needs only 128 choices. My 'gates' either side of center only need a range of 32. Opposite my 5 A2D & I/O board is my line sensor board talking 50 feet away on RS232. My optical sensor uses the full 10-bits // startpulse(10); // Sends SI overlapping CLKOUT pulses to start reading data for ( i = 0; i < array_size; i++) { ckout(); // clk to next pixel set_bit(adcon0, 2); // read analog input0 until adcon0.2 drops to zero while (A2D_not_done); // Wait for a2d done flag to change MAKESHORT(tmp,adresl,adresh); // store data in array photo[i] = tmp; } ckout(); }//END but my display can only handle 8-bit data so I >>2 later. I realize I could shorten things a bit but I like readable code that I can retype easily when I make changes. I tend to make a lot of silly mistakes so I didn't put an array in MAKESHORT ( or maybe I found that it didn't work).
  13. I use one pin for each A2D and read 5 analog values on portA with my 18F252. This accuracy is as good as the A2D on your chip so why use a one wire sensor? This is just some clippings so ignore any extra lines. My delay is probably too long but I have plenty of time in my loop. volatile bit A2D_not_done@0x0FC2.2; // bit 2 of adcon0 trisa = 11111111b; // ALL PORT A inputs trisb = 11110111b; // DON'T BUGGER UP PORTB.0 or .3 trisc = 10000000b; // all Port C outputs except RC7 is RX // initialize ADC for user inputs adcon1 = 00000010b; // // bit 7; 0 = left justify // bit 6; adcs2 FOR CLOCK DIVISION // bits 5,4; not used // bits 3-0; PORT CONFIG; 0010 = AN0...AN4 analog in // // ADCON0 10xxx001 // BITS 7,6; CLOCK DIVISION /32 if ADCON1,6 = 0 // BITS 7,6; CLOCK DIVISION /64 if ADCON1,6 = 1 // BITS 5,4,3; CHANNEL SELECT // BIT 2; GO/DONE // BIT 1; NOT USED // BIT 0; A/D ON // finished initializing ADC // Continuously read setpoint pots // // AN1 = HAPPY : inside inner gates // AN2 = BAND : between inner & outer gates // AN3 = soft_delay : delay before going around loop again // AN4 = contrast : LCD contrast // AN5 = REALC : desired center control point // // Read A1 for desired setpoint adcon0 = 10000001b; // Read from AN0 delay_us(20); set_bit(adcon0, 2); // INNER GATES while (A2D_not_done); // Wait for a2d done flag to change AdRes[1] = adresh; // // Read A2 for desired setpoint adcon0 = 10001001b; // Read from AN1 delay_us(20); set_bit(adcon0, 2); // OUTER GATES while (A2D_not_done); // Wait for a2d done flag to change AdRes[2] = adresh; // // Read A3 for desired setpoint adcon0 = 10010001b; // Read from AN2 delay_us(20); set_bit(adcon0, 2); // SPEED OF LOOP while (A2D_not_done); // Wait for a2d done flag to change AdRes[3] = adresh; // // Read A4 for desired setpoint adcon0 = 10011001b; // Read from AN3 delay_us(20); set_bit(adcon0, 2); // LCD contrast while (A2D_not_done); // Wait for a2d done flag to change AdRes[4] = adresh; // // Read A5 for desired setpoint adcon0 = 10100001b; // Read from AN4 delay_us(20); set_bit(adcon0, 2); // CENTER of control gates while (A2D_not_done); // Wait for a2d done flag to change AdRes[5] = adresh; // I am using +5V & gnd as references but I have had success using four forward biased diodes as a reference and a resistor beyond to limit current. My sensor saturates at about 3V. Of course a voltage reference is smaller and simpler. Keep the sensor range as large as your reference to get the best accuracy.
  14. Being dimmer than most, I often SaveAs another name and then keep on editing my code. When I notice that the hex file is not changing I realize I am editing the new file but compiling the old file ( which has not changed). The obvious symptom is when I click Compile and it says DONE without doing anything.
×
×
  • Create New...