Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Unable to read data from the LTC1296

 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
rosariote



Joined: 22 Jul 2007
Posts: 39

Posted: 29 April 2017, 20:00 PM    Post subject: Unable to read data from the LTC1296 Reply with quote

Hi,
I need some help in the diagnostic why I am experiencing reading the LTC1296. The reading data do not match the voltage input. I am using the ShiftInEx(dataPin, clkPin, bitCnt, flags) with no success. I tried every combination possible in the Shiftin setup but every thing it is been unsuccessful to get a valid reading. To read the data I am setting the format to receive the data as the MSB and sent the command to send it back as MSB. But still the data it is not good. I wrote a manual routine to read it and read it perfectly with no problems. One problem that I see with the Shiftin command it is how to setup it if you want to read the data in the trailing or the leading. Using my routine it read the LTC data faultless and the counts reading coinciding with the input voltage. Right now ran out of ideas on how to solve the problem

I like to use the shiftin command because it require less instructions. Attached it is a file with both routine running on it. I am reading the ltc1296 input port 6.
Any help will be appreciate.

I am using the Scite version 1.62 compile version v4.3.14 Zbasic IDE v1.75



ltc1296_1_4_29_2017.bas
 Description:

Download
 Filename:  ltc1296_1_4_29_2017.bas
 Filesize:  1.87 KB
 Downloaded:  20 Time(s)

Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2982
Location: Portland, OR

Posted: 29 April 2017, 23:07 PM    Post subject: Re: Unable to read data from the LTC1296 Reply with quote

rosariote wrote:
I am using the ShiftInEx(dataPin, clkPin, bitCnt, flags) with no success.
One problem is that the ShiftInEx() call specifies 11 clock cycles - it should be 12, I think.

Secondly, to reproduce something close to your working PulseOut()/GetPin() combination, you should probably configure ShiftInEx() to sample the input before the trailing edge. That would require a 'flags' parameter of &H0A.

Note that the PulseOut()/GetPin() combination actually samples after the trailing edge but the data hold time with respect to the falling edge of the clock could be an issue. The datasheet says that the hold time is typically 130 ns - that's only about two CPU cycles at 14.7MHz.

You could modify read_port_inp() to sample before the falling clock edge thus:
Code:
For  loop_1 = 0 to 11
  Call PutPin(ltc_clk, 1)
  ltc_data_inp  =  (ltc_data_inp  * 2) + cuint(getpin(d_out))
  Call PutPin(ltc_clk, 0)
Next
Back to top
rosariote



Joined: 22 Jul 2007
Posts: 39

Posted: 30 April 2017, 6:05 AM    Post subject: Reply with quote

Hi,
I tried all the combination possible from the table page 238. The table shows all the options. If you select active clock edge that is the leading clock edge
&H00 you can see it is the same as the MSB = &H00. Something it is not right. So you can not select the trailing or the leading from the options.

Did a check by comparing both routine bits reading. Noticed that the bits using the ShiftInEx the bits are stored 3 bits off to the left. If I shift the variable by "shr" 3 times to the right the reading are goods. The reading matched the voltage reading from my voltmeter. Can you explained that. Just by shifting the variable 3 bits right the reading looked good. Normally I found out that most of the basics instructions reading the adc chips have the same problem and needed to use my routine. The problem reading adc it is the company makers do not follow an standard. Question: It is there is a way to find out how the instruction from the Zbasic it is done. I would like to see how it is done.
I am going to update my programs to use the ShiftInEx and shift the variable 3 times right. By doing so do not need to use my routine since it save some instructions.
Thank you for you help. It is late and tomorrow I will be doing some more testing to make sure the reading linearity from 0 to 5 volts are OKAY.
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2982
Location: Portland, OR

Posted: 30 April 2017, 15:19 PM    Post subject: Reply with quote

rosariote wrote:
So you can not select the trailing or the leading from the options.
As with all "flags"-type parameters, individual bits or groups of bits have certain meanings. You combine them to get the desired result.

FunctionBit pattern
MSB first&H00
Sample input before the active clock edge&H02
The active edge is the trailing clock edge&H08
Combined value&H0a


The combination process is by "logical OR". This may be more clearly understood by looking at the Bit Mask column in the Control Flag Definitions table in the description of ShiftInEx(). The x characters in the bit masks means "don't care". From this, you can see that the least significant bit of the flags parameter controls the bit order, bit 1 controls sampling before/after the active edge and bit 3 controls which edge, leading or trailing, is the active edge.

rosariote wrote:
Noticed that the bits using the ShiftInEx the bits are stored 3 bits off to the left.

That is how it works.
ShiftInEx Description wrote:
If MSB order is specified, the first bit read will be in the most significant bit position of the result.
Back to top
rosariote



Joined: 22 Jul 2007
Posts: 39

Posted: 30 April 2017, 18:55 PM    Post subject: Reply with quote

Hi,
I did not know what I was doing but tried the different combinations in the table with not luck as you explained. Like I said before. I encountered same problem with other basics micro reading ADC and end using my routine.
Today checked the voltage linearity and it is right on.

I would like to thank you for taking your time to give me some advice but I think there are nothing to do just shift the variable 3 times to the right to fix the problem.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Language Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2017 Elba Corp. All rights reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group