Code Monkey home page Code Monkey logo

pipowermeter's People

Contributors

djacobow avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

pipowermeter's Issues

SPI Communication

I am using Rpi 3b+ to communicate with ATM90e26 using SPI mode. However it doesn't seem to be working. This is how im implementing the code.

	# to communicate with the ic 
        # RW is 1 / 0 for read or write operation 
        # address as the name suggests points to a specific register
        # val is the value to be written during write operation
        def comm_atm90(self,RW,address,val): 
		#switch MSB and LSB of value
		buf = bytearray(2)
		#Set read write flag
		address|=RW<<7
		self.spi.open(0,0)
                self.spi.max_speed_hz = 200000
                self.spi.mode = 0b11
                self.spi.lsbfirst = False
                self.spi.bits_per_word = 8
		time.sleep(0.000010)
		self.spi.writebytes([address])
		''' Must wait 4 us for data to become valid '''
		time.sleep(0.000004)

		#Read data
		#Do for each byte in transfer
		if(RW):
			buf = self.spi.readbytes(2)
		else:
			self.spi.writebytes([val])			 # write all the bytes
		self.spi.close()
		return int.from_bytes(buf,'big')

i am using spidev module as

import spidev
spi = spidev.SpiDev()

# lets say after the init functions i call the checksum 1 register
print(hex(self.comm_atm90(True,CSOne,0x0000)))

The output i get is0x0everytime. A similar implementation using ESP32 on micropython works just fine!!! Is there something wrong that i might be doing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.