A
pidyon haben (redemption of the firstborn son) is not dependent on whether a woman went to the mikveh before conceiving.
If a woman
miscarried within forty days after conception (usually forty days after going to the mikveh, in halachic terms), her next child is considered her firstborn, and, if a boy, should have a
pidyon haben.
If the miscarriage occurred more than 40 days after conception, there will be no
pidyon haben unless there was no "
rikum" (tissue). If there is doubt as to whether or not there was tissue in the miscarriage, then a pidyon is required without a bracha and with the kohen having in mind to return the money. We suggest discussing this point with a local rabbi if it becomes relevant.