Jump to content

rfhaley

EstablishedMember
  • Content Count

    77
  • Joined

  • Last visited

Everything posted by rfhaley

  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 s
  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 ha
  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
  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 kn
  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 hi
  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
  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 CLO
  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.
  15. I would bash my way through with something like: if(porta,1)==0 { ... } and I would have thought that test_bit was a boolean answer so I guess I would write my own when it didn't work. How about using test_bit ==0 or !=0 as the test criterion instead of ==1. This gets away from how many bits we have to deal with. I would also get away from talking about porta,1 & ra1. We know porta,1 works so replace all the ra1 & ra0. Then the code is not so dependant on the chip memory.
  16. I would guess that if you are using analog In then the comparator is not used so CMCON is irrelevant. ANSEL would be 00000001b, ADCON0 = x0100001 ADCON1 you choose the speed, TRISA =10010000. see how that works. I'm a beginner too. Just been 8 years on & off.
  17. Try commenting out the definitions @specific memory locations char ADCon0@0x1F; char ADCon1@0x9F; char ADResH@0x1E; char ADResL@0x9E; If that still leaves errors try removing the quotes in set_bit(STATUS, 'RP0'); ADCon1 = 00000100b; clear_bit(STATUS, 'PRO'); and be certain that PRO is a defined register. If that helps I'll be as astonished as you!
  18. Yes I think you are right - Regarded as a definate treat by children if they survived chimney sweeping. Regards Dave <{POST_SNAPBACK}> I prefer to think we are more Edwardian, running around naked and carefree. It's -36C here and you want ME to get out of bed to push a button?
  19. I finally noticed that option quietly changed from the example to option_reg in Pavel's post. That seems like a large change to me since the error disppeared when I tried it. Option, as in the original example was a regular variable, not a SFR. I'll email a functioning 12F629 example for your page. It flashes 20 LEDs and requires the child to push a button after a time so the batteries won't run down. I wish my brain was more pliable so that learning wouldn't hurt so much.
  20. I see the same errors. Once the offending vars are removed code compiles with no prob: Regards, Pavel <{POST_SNAPBACK}> Back to the original post: I am using SourceBoost V6.55, 12F629, BoostC. If I comment out all the char "register", as you did, it will not compile. I get an error when I comment out: char option... This was my original question. Why is option different from trisio, etc? Apparently it is not, where you live. When I created my project I changed the target to 12F629. That is all I changed, did I miss something? I can compile if I declare char option@
  21. I tried to reproduce this problem but didn't see any crash. Just a compile error (expected one). What is your definition of the phrase "compiler crashed"? Regards, Pavel <{POST_SNAPBACK}> OK. So I am a bit blunt. doesn't work = crash. What error did you expect in example code? C2C compatibility? I see several messages : error: variable "trisio" already exists, same for cmcon, intcon & gpio. I saw fewer messages today until I noticed that I was compiling for 16F84A I have no trouble running complementary LED drive on the EZ controller but I have some 12F629 on
  22. I copied the demo C2C program - Sample code for PIC12F629/675 processors and started a project for a BoostC V6.55, 12F629, 20 LED chaser for xmas. It crashes on the char definitions #include <system.h> char option@0x81; char trisio@0x85; char gpio@0x5; char intcon@0x0B; char cmcon@0x19; char led = 1; void interrupt( void ) { if( led ) { gpio = 7; led = 0; } else { gpio = 0; led = 1; } intcon &= 0xFB; } void main() { option = 3; //set prescaler to 1:16 trisio = 0; //set all IOs to output //ansel = 0; cmcon = 7
  23. Yes, but I must remember that the number I choose to subtract is only one of the parts being subtracted. The farther I am from displaying 0-32 the faster I want to respond. Even with these strange numbers it can take 2 seconds to stabilize. When clk is low my loop runs about 10/sec. Any faster and my LCD fades into grey on white. When the light is dimmer the integration time is longer to collect more light so I loop around slower; as low as 2/sec. Maybe if I had one process reading samples and another displaying? Novo rtos? Still my serial display seems to be the limiting code. A parallel di
  24. All better. The multiple if statements can overlap and add together so I reduced them. Example: maxht > 2000 subtracts 100,60,45,25,8 & 4. Clk is also given a lower bound (it must have gotten lost somewhere). void CheckBright(void) { // // all display bits raised by *4 in V7.4 // using 10 bit A2D data in photo[i] // shifted 2 bits right for display on 32 pixel display if (maxht > 2000) clk -= 100; // AIEEE! if (maxht > 960) clk -= 60; // WAAY Too Bright if (maxht > 480) clk -= 45; // Far Too Bright if (maxht > 240) clk -= 25; // Too Bright if (maxht > 160) clk -= 8
×
×
  • Create New...