Hey Henrik,
I guess it doesn't really matter what the modbus code said because I am revamping it. I didn't actually write that code, or at least the communication part. I copied it from someone else's work. It only had a couple of modbus functions and it used an I2C chip to read and write to registers. So I modified it. As far as I can tell, the codes TMR interrupts every 98mS which is way to long and that might have been part of my problem.
@20Mhz and a 1:16 pre-scaler TMR1 Variable counts to 120, this is my math for it.
1/5000000=200nS 200nS*16=3.2uS 3.2uS*256=819.2uS
819.2uS*120=98.304mS
In post #7 I forgot to figure in the 8bit PR2 register.
So, check my math if you would, what I need to do is.....
@40Mhz-1:16 pre-Scaler-8bit TMR
I need my TMR Counter Variable to count to 10.
40Mhz/4=10Mhz 1/10Mhz=100nS 100nS*16=1.6uS 1.6uS*256=409.6uS
409.6uS*10=4.096mS
Thats way closer to 4mS then it was unless my math is wrong. I am going to try and scope it to see what I get
Shawn




Bookmarks