Read 2 parallel bit data

I am a newbie to the Arduino and I hope to get help from you guys.
I have an ADC with 2-3 bits parallel bins output , I am want to read the parallel port using Digitalread() then print into the serial monitor as parallel data.

  • please provide information on exact model / link to where you got it
  • what did you try?

Part number?  Datasheet?

this is the MAXI2771(https://datasheets.maximintegrated.com/en/ds/MAX2771.pdf ) with 2-3 bits binary output

this is a Multiband Universal GNSS Receiver not an ADC

EDIT: sorry it does have an ADC

I did a standard digital read code and serial print ,
/*
DigitalReadSerial

Reads a digital input on pin 2, prints the result to the Serial Monitor

This example code is in the public domain.

https://www.arduino.cc/en/Tutorial/BuiltInExamples/DigitalReadSerial
*/

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = PA3;

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(115200);
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
Serial.println(buttonState);
}

that should work to read the state of a pin indeed


please edit your post, select the code part and press the </> icon in the tool bar to mark it as code. It's barely readable as it stands. (also make sure you indented the code in the IDE before copying, that's done by pressing ctrlT on a PC or cmdT on a Mac)

So you can use that kind of logic to read any number of digital inputs, then some straightforward calculation to assemble the bits in a variable for further use as a number.

If it is important to either be somewhat quicker about it or to grab all the bits at a single moment, you can use direct port reading to get all the bits in at once parallel.

It's very simple, I suggest you to google

Arduino direct port manipulation 

and poke around. See what may have been hidden from you for all this time.

Direct use of a port needs only three registers. One for setting the pins to be either input pins or outputs; one for reading from the pins and one for writing to the pins.

Look at some examples. You may need to grab up some knowledge about the various means for dealing with the bits in a variable. True low level fun.

a7

I did some quogling
teensy 4.1 read port

and found this

which links to

The polling method would be to
to do

and then use

to put the three bits into a variable
best regards Stefan

This is the code in a better victuals

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = PA3;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(115200);
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int buttonState = digitalRead(pushButton);
  // print out the state of the button:
  Serial.println(buttonState);
}

thank you for the advice I will give it a try and will update u on the situation.
I got one more question : is it possible to print these parallel data into a txt file for processing ?

thank you Stefan, the links you add are very useful.

I don't know. This is the arduino forum. Maybe you have luck and somebody that is using arduino also has knowledge about processing

A simple altermative would be to use any kind of standard terminal program. Most of them have a log-to-file-function

I did some quogling
https://www.google.de/search?as_q=processing+receive+serial+data+write+to+file

and found this

best regards Stefan

hello Stefan
I am using stm32 nucleo-H743ZI2 board with 480 mhz cpu speed, does doing a digitalread, or port manipulation will be able to read a 4MSpS ADC that using the Arduino API, prior to printing it.
best regards Ahmed

Have you read the data sheets and attempted an evaluation?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.