summaryrefslogtreecommitdiff
path: root/Resources/OpenPLCv2/firmware/ADC.test.arduino/trial2.c
diff options
context:
space:
mode:
authorVishnu Easwaran E2020-08-10 12:44:59 +0530
committerGitHub2020-08-10 12:44:59 +0530
commitc76c13209edef0efe7562685ba1b3b7017221679 (patch)
tree7e531c6afdad83ad9e6781c5e0ea42e23f5c3784 /Resources/OpenPLCv2/firmware/ADC.test.arduino/trial2.c
parent381c57f811249833341c0e394fb48460d4b175b1 (diff)
parentc3659645dd417f5c35424f7c174597d0ffd7e926 (diff)
downloadOpenPLC-c76c13209edef0efe7562685ba1b3b7017221679.tar.gz
OpenPLC-c76c13209edef0efe7562685ba1b3b7017221679.tar.bz2
OpenPLC-c76c13209edef0efe7562685ba1b3b7017221679.zip
Merge pull request #12 from VishnuEaswaran/vishnuDev
Updating repo structure and documentation
Diffstat (limited to 'Resources/OpenPLCv2/firmware/ADC.test.arduino/trial2.c')
-rw-r--r--Resources/OpenPLCv2/firmware/ADC.test.arduino/trial2.c60
1 files changed, 0 insertions, 60 deletions
diff --git a/Resources/OpenPLCv2/firmware/ADC.test.arduino/trial2.c b/Resources/OpenPLCv2/firmware/ADC.test.arduino/trial2.c
deleted file mode 100644
index e8cdfcf..0000000
--- a/Resources/OpenPLCv2/firmware/ADC.test.arduino/trial2.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-
-SSTRB goes low when the ADC begins a conversion and goes
-high when the conversion is finished
-
-SSTRB goes low at the beginning of calibration and goes
-high to signal the end of calibration
-
-Control byte format
-7 - (MSB) START The first logic "1" bit, after CS goes low, defines the beginning of the Control Byte
-6 - UNI/BIP 1 = unipolar, 0 = bipolar
-5 - INT/EXT Selects the internal or external conversion clock. 1 = Internal, 0 = External.
-4 - M1 M1 M0 MODE
-3 - M0 0 0 24 External clocks per conversion (short acquisition mode)
- 0 1 Start Calibration. Starts internal calibration.
- 1 0 Software power-down mode
- 1 1 32 External clocks per conversion (long acquisition mode)
-2 - programmable bit P2
-1 - programmable bit P1
-0 - programmable bit P0
-
-*/
-
-#define CALIBRATION 0b11101000
-#define START 0b11100000
-
-#include <SPI.h>
-int sstrb = 8;
-int adcPin = 9;
-int sdPin = 10;
-unsigned int adcValue = 0;
-byte LowByte,HighByte;
-
-void setup() {
- pinMode(sstrb,INPUT);
- pinMode(adcPin, OUTPUT);
- pinMode(sdPin, OUTPUT);
- digitalWrite(adcPin,HIGH);
- digitalWrite(sdPin,HIGH);
- Serial.begin(115200);
- SPI.begin();
- SPI.setBitOrder(MSBFIRST);
- SPI.setClockDivider(SPI_CLOCK_DIV4);
- SPI.setDataMode(SPI_MODE0);
- delay(100);
- digitalWrite(adcPin,LOW);
- SPI.transfer(CALIBRATION); //kalibrálás
- while(!digitalRead(sstrb)){}
- SPI.transfer(START); //mérés indítás
-}
-
-
-void loop(){
- while(!digitalRead(sstrb)){}
- adcValue=SPI.transfer(START);
- Serial.print("ADC: ");
- Serial.println(adcValue);
-
-
-} \ No newline at end of file