On Friday, October 3, 2014 10:20:18 AM UTC-6, ton...@gmail.com wrote: > > Have you fried the chip, with an overvoltage? > > Em segunda-feira, 29 de setembro de 2014 05h12min08s UTC-3, Anshuman > Rajwar escreveu: >> >> Hello >> >> I am trying to control an AD7490 16 channel ADC using spi0 on the >> beaglebone black, currently I am using a very simple code where all I want >> to do is get the ADC to read first channel i.e (channel 0) and return the >> value it gets, however it seems that the only two values that AD7490 >> returns are 255 and 16. Below is the code I am using >> #!/usr/bin/python >> >> from Adafruit_BBIO.SPI import SPI >> import time >> >> >> >> >> spi = SPI(0,0) >> spi.msh=1000 >> spi.open(0,0) >> spi.bpw=16 >> keepRunning=True >> n=0 >> >> def readVoltages(n): >> >> print("\n"+"talking to the ADC") >> readings=spi.xfer([65535,65535,(2097<<4)]) >> print("output from first one"+"\n") >> print(readings) >> print("\n") >> print("I am awake now") >> print("\n") >> readings=spi.xfer([(2097<<4)]) >> print("This is what processor gave back "+"\n") >> print(readings) >> print("This is what the reading is "+"\n") >> print(readings[0]&4095) >> print("\n") >> adcOutput=readings[0]&4095 >> n+=1 >> return adcOutput,readings,n >> >> >> while(keepRunning): >> adcOutput, readings,n=readVoltages(n) >> y_or_n=raw_input("Should I run again??") >> print("\n"+y_or_n) >> if(y_or_n is "n"): >> keepRunning=False >> n+=1; >> print "I finished **********************" >> spi.close() >> Below is my output >> >> talking to the ADC >> output from first one >> >> [255, 255, 16] >> >> >> I am awake now >> >> >> This is what processor gave back >> >> [16] >> This is what the reading is >> >> 16 >> >> >> Should I run again??n >> >> n >> I finished ********************** >> >> The structure of the control register of AD7490 is below >> >> 11 10 9 8 7 6 5 4 >> 3 2 1 0 >> WRITE SEQ ADD3 ADD2 ADD1 ADD0 PM1 PM0 SHADOW WEAK/TRI RANGE CODING >> >> >> The word size is 16 bits so when I want to program this ADC to read only >> first channel I send >> 2097<<4. But I always get 16, it does not matter whether I am applying >> any voltage to the ADC or not. >> >> Please help me, its a very simple code and I cant think of a reason that >> it is not working. >> >> >> >> I don't think so because all the voltages that I have applied are in accordance with the data sheet provided by AD and the circuit provided by them, and I noticed another thing the SPI returns last 5 bits that I send so clearly it at least communicating. I also asked Analog Devices tech support and they asked me to make sure that all my timings are correct I am trying to understand how to use spidev.c to get better control of timings but let us say what you are saying is correct how can I check if chip is damaged
-- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.