
Originally Posted by
enauman
I assume you are making analog measurements.
Your assumption is wrong.

Originally Posted by
25HenrikOlsson
How do you transfer the data from the PIC to the PC?
I'm a bit confused about your math... You say you need 500Kbs (which is quite a bit), but then you say you want 500 measurements per second. With an ADC resolution of 10 bits (each measurement taking two bytes) that's 1000 bytes per second which would be around 100Kbs. Never the less, the bottleneck is probably in the datatransfer itself.
Is it a continous stream of samples or is it a defined amount of samples at a certain sample rate or what exactly are you trying to do. The 4550 has 2k of ram so depending on what else your program is doing you might be able to store the samples in RAM and then transfer them to the PC - but again, it all depends on what you're doing.
Hi Henrik,
I need to clarify my original post. The 500Kbps is the speed of the CAN network and there are about 500 messages a second. I know the 4550 can do this because the demo boards do it with no problems so it's an issue within my code. Actually, I've seen the demo boards handle 1100 messages a second. Again, I'm not sure if it's the VB code or it's the PIC code. Here is what I have for the PIC code:
Code:
START:
RxBuffer = 0 'clear flag
Low CS
SSPBUF = %00000011 'read command
GoSub letclear
SSPBUF = CANINTF 'buffer flags are contained in this mcp2515 can controller register
GoSub letclear
SSPBUF = 0 'clock it out
GoSub letclear
RXDATA = SSPBUF 'receive buffer status
High CS
RxBuffer = RXDATA & %00000011 'isolate last two bits
If RxBuffer > 0 Then
'a buffer is full, or 3, then both are full
If (RxBuffer = 1) Or (RxBuffer = 3) Then
RxBufferSub = 1
DATA35=1 'VB LED
GoSub ReceiveCanSub0
EndIf
If (RxBuffer = 2) Or (RxBuffer = 3) Then
RxBufferSub = 2
DATA35=1 'VB LED
GoSub ReceiveCanSub1
EndIf
GOTO START
ReceiveCanSub0:
LED_RX=0
Low CS
SSPBUF = 3 'read
GoSub letclear
SSPBUF = RXB0DLC + (RxBufferSub - 1) * 16 'receive buffer of data bytes offset 16
GoSub letclear
SSPBUF = 0 'dummy clock it
GoSub letclear
RXDATA = SSPBUF 'should contain the number of data bytes
High CS
DataBytesRx0 = RXDATA & %00001111 'bits 0-3 contain the number of data bytes
DATA1=DATABYTESRX0
If DataBytesRx0 > 0 Then
For i = 0 To DataBytesRx0 - 1 '(say data is 2, then 0 and 1)
Low CS
SSPBUF = 3
GoSub letclear
SSPBUF = (RXB0D0 + (RxBufferSub - 1) * 16) + i
GoSub letclear
SSPBUF = 0 'dummy clock
GoSub letclear
RXDATA = SSPBUF 'mcp2515 can controller data
High CS
CanDataRx0 [i] = RXDATA
DATA2 = CanDataRx0[0]
DATA3 = CANDATARX0[1]
DATA4 = CANDATARX0[2]
DATA5 = CANDATARX0[3]
DATA6 = CANDATARX0[4]
DATA7 = CANDATARX0[5]
DATA8 = CANDATARX0[6]
DATA9 = CANDATARX0[7]
Next
EndIf
Low CS
SSPBUF = 3 'read
GoSub letclear
SSPBUF = RXB0SIDH + (RxBufferSub - 1) * 16 'high identifier
GoSub letclear
SSPBUF = 0 'clock spi
GoSub letclear
RXDATA = SSPBUF 'identifier
High CS
CanRxIDHigh0 = SSPBUF
Low CS
SSPBUF = 3 'read
GoSub letclear
SSPBUF = RXB0SIDL + (RxBufferSub - 1) * 16 'low identifier
GoSub letclear
SSPBUF = 0 'clock spi
GoSub letclear
RXDATA = SSPBUF 'identifier
High CS
CanRxIDLow0 = SSPBUF
'now, clear the buffer!
'use bit modify...
Low CS
SSPBUF = %00000101 'bit modify command
GoSub letclear
SSPBUF = CANINTF 'mcp2515 can controller interrupt flags
GoSub letclear
SSPBUF = RxBufferSub 'mask for buffer number n
GoSub letclear
SSPBUF = %00000000 'clock in a clear bit
GoSub letclear
High CS
LED_RX=1
DATA35=0 'VB LED
Return
Bookmarks